Re: Caching values in service and browser refresh

378 views
Skip to first unread message

Dan Doyon

unread,
Jun 28, 2012, 5:40:55 PM6/28/12
to ang...@googlegroups.com

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?


On Thursday, June 28, 2012 1:46:34 PM UTC-7, bsr wrote:
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 below

angular.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.

Reply all
Reply to author
Forward
0 new messages