AngularJS REST request caching

I am new to angularJS and am wondering about caching etc.

I have a wizard with two steps, I want to be able to click back and then fill out the forms that their users had.

In my 1Partial page, I have this:

<li ng-repeat="pick in picks | orderBy:orderProperty"> <b><span ng-bind="pick.name"/></b> <input type="checkbox" ng-model="pick.checked" ng-click="updateBasket(pick)"> </li> 

When I move to the next page, click the "Back" button, and the checkboxes will be cleared, because my RESTIVE call for the java service is called again. How can I cache this answer?

From my controller, it gets to my REST web service every time.

 $scope.picks = Pick.query(); 

My service

 angular.module('picksService', ['ngResource']). factory('Pick', function ($resource) { return $resource('rest/picks/:id', {}, { 'save': {method: 'PUT'} }); }); 
+6
source share
2 answers

Starting with version 1.1.2 ( commit ), all $ httpConfig parameters are displayed directly in the $ resource action objects:

 return { Things: $resource('url/to/:thing', {}, { list : { method : 'GET', cache : true } }) }; 
+19
source

if you replace $resource with $http then you can directly use the code below

 $http({ method: 'PUT', url: 'url', cache:true }); 
+10
source

All Articles