When I load my modal HTML page for the first time, I get the proper data. However, when I try to load it a second time, an error occurs.
Below is my JS code:
var cache = $cacheFactory('cacheId');
var cacheData = cache.get('xml');
if (!cacheData) {
MyRestApi.getData($scope.data1).then(function(response) {
cacheData = response;
cache.put('xml', cacheData);
});
} else {
var processdata = cache.get('xml');
}
In MyRestApi.js, the following code is used:
getData: function(Key) {
return $http.get(baseURL + '/getDetails/' + Key, {
headers: header,
cache: true
});
}
This is my first time using $cache in AngularJS. Please help me understand why I am encountering this error. The error occurs when I try to load the same modal page for the second time.
Angular.js:13568 Error: [$cacheFactory:iid] CacheId 'cacheId' is already taken!