简体   繁体   English

如何取消RestAngular promise .then()?

[英]How to cancel RestAngular promise .then()?

How to cancel RestAngular promise .then()? 如何取消RestAngular promise .then()? I am not sure how to cancel promise/xhr request in restangular/$http - it's fairly simple in jQuery. 我不知道如何在restangular / $ http中取消promise / xhr请求 - 这在jQuery中相当简单。

You can abort $http calls via the timeout config property, which can be a Promise, that aborts the request when resolved. 您可以通过timeout config属性中止$http调用,该属性可以是Promise,在解析时中止请求。

So in restangular, you can do this like 所以在restangular中,你可以这样做

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

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM