Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularjs: how to add caching to resource object?

To add caching inside http is pretty straight forward. ( by passing cache=true )

http://docs.angularjs.org/api/ng.$http has Cache option.

How do I add similar functionality in $resource in angularjs ?

like image 452
iamgopal Avatar asked Sep 01 '12 06:09

iamgopal


People also ask

What is $resource in Angularjs?

Overview. A factory which creates a resource object that lets you interact with RESTful server-side data sources. The returned resource object has action methods which provide high-level behaviors without the need to interact with the low level $http service. Requires the ngResource module to be installed.

What is .angular cache?

By default, . angular/cache is used as a base directory to store cache results. To change this path to .cache/ng , run the following command: content_copy ng config cli.


1 Answers

Since 1.1.2 (commit), all the $httpConfig options are directly exposed in $resource action objects:

return {   Things: $resource('url/to/:thing', {}, {     list : {       method : 'GET',       cache : true     }   })  }; 
like image 83
Narretz Avatar answered Sep 22 '22 15:09

Narretz