I am currently working on a service that has two methods. Utilizing the built-in cache support for $resource, I am trying to implement a way to refresh the cache when a service call is made from the controller. I attempted to use $cacheResource without success. Below is my code:
Service
angular.module('module').factory('Service1',['$resource',
function ($resource){
return $resource('..api/latest/myservice', {}, {
takeSomething: {
method: 'GET',
url: '..api/latest/myservice/takesomething',
cache: true
},
putSomething: {
method: 'GET',
url: '..api/latest/myservice/putsomething',
cache: true
}
}
}]
Controller
angular.module('module').factory('MyController',['$scope','Service1',
function($scope, service1) {
....
$scope.update = function() {
service1.putSomething({
......
refresh cache for takeSomething method in service or for all methods
});
}
}
When the update function is called from the controller, I aim to refresh the cache for the takeSomething method or for all methods.