AngularJS高速缓存的REST请求 [英] AngularJS Caching a REST request
问题描述
我是新来angularJS并有一个关于缓存等等问题。
我有两个步骤的向导,我希望能够单击后退和明年,并有仍然填写的用户让他们的表格。
在我的page1Partial我有这样的:
<李NG重复=挑精选|排序依据:orderProperty>
< B><跨度NG绑定=pick.name/>< / B>
<输入类型=复选框NG模型=pick.checkedNG点击=updateBasket(挑)>
< /李>
当我去到下一个页面,然后点击后面的checkboxs被清除,因为它给我的Java服务RESful再次被调用。我怎样才能缓存对此有何反应?
从我的控制器,每次都打我REST Web服务。
$ scope.picks = Pick.query();
我的服务
angular.module('picksService',['ngResource'])。
工厂('挑',函数($资源){
返回$资源('休息/根/:身份证',{},{
保存:{方法:把'}
});
});
由于1.1.2(<一个href=\"https://github.com/angular/angular.js/commit/af89daf4641f57b92be6c1f3635f5a3237f20c71\">commit),所有$ httpConfig选项直接暴露在$资源操作的对象:
{回报
物联网:$资源(URL /到/:东西',{},{
清单:{
方法:GET,
缓存:真
}
})
};
I'm new to angularJS and have a question about caching etc.
I have a wizard with two steps, I want to be able to click back and next and have the forms still filled out as the user had them.
In my page1Partial 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 go to the next page, then click back the checkboxs are cleared, and its because my RESful call to a java service is called again. How can I cache this response?
From my controller, this hits 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'}
});
});
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
}
})
};
这篇关于AngularJS高速缓存的REST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!