factory('Menus', function ($q, $http) {
api_url = 'http://api/menu';
var respose_json = function () {
var deferred = $q.defer();
deferred.resolve(
$http.get(api_url, {cache: true}).success(function (result) {
return result;
}));
return deferred.promise;
};
return {
all: respose_json,
get: function (id) {
return respose_json[id];
}
};
})
I’m trying to use cache to hold json data fetched from web so that after switching tabs, content will be ready without re-fetching. But, the content disappears every time switching tabs.
Is there anyway I can hold the data locally or in cache?