angularjs - angular CacheFactory doesn't set any value -
i'm having issue cachefactory module , problem not set anything!
here code, logically when first time code run, second time when refresh page should show me value doesn't , it's 'undefined'
function itemfcy($http,$q,cachefactory) { var items={}; var factory = { getitems: }; return factory; function get() { var cache= cachefactory.get('itemscache'); console.log("cache value is:"+cache); var deferred = $q.defer(); $http.get('/items.json') .success(function(data, status, headers, config) { items= data; cachefactory.createcache('itemscache',items); deferred.resolve(sliders); return deferred.promise; }) .error(function(data, status, headers, config) { console.log("error on loading items"); }) return deferred.promise; }
it print
cache value is:undefined
why doesn't set anything?
i think should using localstorage
rather cachefoactory
ng-storage might helpful you.
Comments
Post a Comment