所以我有一个创建缓存对象的简单工厂
.factory('jsonCache',function($cacheFactory){
console.log("Creating cache");
return $cacheFactory('weatherCache');
});
然后我通过像这样传递它来调用我的控制器内部的缓存对象。但由于某种原因,数据不是持久的。每次我重新加载页面时,缓存又是空的。
有任何想法吗?我错过了什么?
.controller('citiesListCtrl',function($scope,$http,$filter,jsonCache){
jsonCache.get('weatherCache');
console.log(jsonCache); <----- EMPTY
$http.get(url)
.then(function(response) {
jsonCache.put('weatherCache', response.data.records);
console.log(jsonCache); <--- HAS DATA
});
)}