简体   繁体   中英

What is the equivalent to jQuery REST request promises like .success and .error in AngularJS?

It's a pretty self explanatory question. I'm seeing a few ways that people handle errors, I'm wondering if one way is recommended over another, and what is the best practice.

Angular $http provider returns promise, which gives ability to subscribe on error event, because promise resolves in 3 ways: success, error and then.

So it is common to use this promise inside and outside - you can return it from service and use in the controller.

Don't create new promise if you have one, which resolves in the moment you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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