It seems pretty clear how to set a global method to abort http requests. Something along the lines of
$scope.canceller = $q.defer();
var API = $resource('http:/foo.com', {}, {get: {
method:'GET',
timeout:$scope.canceller.promise
}});
$scope.abortRequests = function() {
$scope.canceller.resolve();
}
However, I want to be able to abort only specific requests. I could define separate resource for the requests I need to be able to abort, but that's pretty ugly. Is there any way I can pass in a parameter or something when I call the $resource that could allow the timeout to be conditional? Maybe along the lines of:
var API = $resource('http:/foo.com', {}, {get: {
method:'GET',
timeout:function() { if (FOO) { return $scope.canceller.promise; }}
}});
But how do I access FOO?
Thanks for any insight!