below I use query to get llist of messages, for saving I pass in a messageId when I call it.
.factory('FooSvc', function ($resource) {
return $resource('../foo/messages/:messageId', { format: 'json' }, {
'query' : { method: 'GET', isArray: false },
'save' : { method: 'PUT', params: { messageId:'@messageId'} },
});
})
-- controller snippet
var somelist = Foo.query();
foo.save({messageId: 123});
Am I missing something?
With the help of community and the tutorials, I learned how to use session to encapsulate data and inject into various controllers. Now, in my application, I am trying to cache a request like belowangular.module('myApp.services', ['ngResource']).factory('Play', function($resource, $routeParams){var Play = {resource: function() {return $resource('/api/Play/:_id', {} )} ,initplay: $resource('/api/Play/:_id', {} ).get({_id:$routeParams._id})};return Play});initplay is initialized correctly and I could share it across controllers. Now, if I navigate away to other views, it all works till I refresh the browser window. The problem is that in some views I don't keep _id as part of url anymore. Is this a bad practice, or how should I handle this.