Skip to content

Instantly share code, notes, and snippets.

@ReedD
Created April 29, 2014 18:07
Show Gist options
  • Save ReedD/11407788 to your computer and use it in GitHub Desktop.
Save ReedD/11407788 to your computer and use it in GitHub Desktop.
AngularJS - Cancel http request before completion.
var canceler = $q.defer();
$http.get('/someUrl', {timeout: canceler.promise}).success(successCallback);
// later...
canceler.resolve(); // Aborts the $http request if it isn't finished.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment