Hi Sander,

I used a hardcoded string with a TODO comment, and just saw that again 
today hence the late response...
Thank you very much for your suggested solution. As a way of doing caching 
on $resource this is great. 

However, am happy with localStorage and encryption. In order to clear the 
TODO items, what would help is knowing how to query a $resource for its URL 
(the same one passed into its constructor on creation) ?  Is there an easy 
way to do that? If i read your solution correctly, you already assume the 
caller knows the URL in advance - i have the opposite problem, a $resource 
without knowledge of its URL.

As always, thank you for your help.

Richard.



On Saturday, October 25, 2014 3:15:22 PM UTC+9, Sander Elias wrote:
>
> Hi Richard,
>
> Before I dive in deeply into this, why don’t you just build your own 
> service for doing this?
>
> something like:
>
> (function () {
>
>     cachedResource.$inject = ['$resource'];
>     function cachedResource($resource) {
>         var cache = {};
>         return function (url, paramDefaults, actions, options) {
>             if (cache[url]) {
>                 return cache[url];
>             }
>
>             cache[url] = $resource(url, paramDefaults, actions, options);
>
>             return cache[url];
>         };
>     }
>
>     angular.module('myApp',[])
>      .service('cachedResource', cachedResource);
>
> }());
>
> Is that something you can use?
>
> Regards
> Sander
> ​
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to