angular缓存jsonp数据:
参考自:https://www.chedanji.com/angularjs-cache-for-jsonp/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| angular.module('app',[]) .factory("myCache", function($cacheFactory){ return $cacheFactory("me"); }) .controller("AppCtrl", function($http, myCache){ var app = this; app.load = function(){ $http.get("apiurl",{cache:myCache}) .success(function(data){ app.data = data; }) } app.clearCache = function(){ myCache.remove("apiurl"); } })
|