I am calling web service in angular js . I am able to get data using $http.But I create a situation when I want to cancel my request after few seconds .I call service after 2 second .then press cancel request button .on click of that button I need to cancel my request which is try to get data from server .can we do in angular js to cancel request
here is my code
.factory('acservice', ['$http','$q', function($http,$q) {
var canceler = $q.defer();
return {
callDisputeServiceLocal: function(successcallback, errorcallback) {
return $http.get('https:/******.com/s/9wkl32e23vdvs6h/default.json?dl=0',{timeout: canceler.promise}).success(successcallback).error(errorcallback);
},
cancelRequest:function(){
canceler.resolve();
}
}
Edit already use this but not working