Despite attempting various solutions, such as the one mentioned in this thread, I am still unable to successfully cancel a request made using $resource. My latest attempt looks like this:
Controller:
angular.module('theApp')
.controller('homeController', function ($q, foodTypeFactory) {
var vm = this;
vm.testButton = function () {
vm.aborter = $q.defer();
foodTypeFactory(vm.aborter).getTest({}, function (data) {
console.log(data);
});
};
vm.cancelButton = function () {
vm.aborter.resolve();
}
});
foodTypeFactory:
angular.module('theApp')
.factory('foodTypeFactory', function ($resource, BACKEND_API) {
return function (aborter) {
return $resource(BACKEND_API + '/api/foodtypes/:id', {id: '@id'}, {
getTest: {
timeout: aborter.promise
}
});
}
});
Even after trying to cancel the request, it still goes through and completes. I'm working with Angular version 1.6.2 and angular-resource 1.6.2.
What could be the issue here?