angularjs:如何添加缓存资源的对象? [英] angularjs: how to add caching to resource object?

查看:151
本文介绍了angularjs:如何添加缓存资源的对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要添加缓存里面HTTP是pretty直线前进。 (通过传递缓存= TRUE)

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

http://docs.angularjs.org/api/ng.$http 具有高速缓存选项。

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

我如何在$资源中angularjs加入类似的功能?

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

推荐答案

由于1.1.2(<一个href=\"https://github.com/angular/angular.js/commit/af89daf4641f57b92be6c1f3635f5a3237f20c71\">commit),所有$ httpConfig选项直接暴露在$资源操作的对象:

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:如何添加缓存资源的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆