eugenekgn
eugenekgn

Reputation: 1722

How to cancel RestAngular promise .then()?

How to cancel RestAngular promise .then()? I am not sure how to cancel promise/xhr request in restangular/$http - it's fairly simple in jQuery.

Upvotes: 4

Views: 1411

Answers (1)

jakee
jakee

Reputation: 18566

You can abort $http calls via the timeout config property, which can be a Promise, that aborts the request when resolved.

So in restangular, you can do this like

var abort = $q.defer();
Restangular.one('foos', 12345).withHttpConfig({timeout: abort.promise}).get();
abort.resolve();

Hope this helps!

Upvotes: 3

Related Questions