Ajax成功vs然后(角度承诺)

Ajax成功vs然后(角度承诺)

问题描述:

我打算在我的应用程序中使用angularjs promise。但是我没有得到.success函数和.then函数之间的实际区别。Ajax成功vs然后(角度承诺)

+0

可能重复http://*.com/questions/16385278/angular-httppromise-difference-between-success-的error-methods-and-thens-a –

+2

[Angular HttpPromise:\'success \'/ \'error \'methods和\'然后\''参数之间的区别]的可能副本(http://*.com/问题/ 16385278 /角httppromise差之间成功 - 误差的方法和 - thens-a)的 –

1. advantages of promises is the ability to flatten and chain potentially complex sequences of ajax calls. Not only does this help us simplify code, but more importantly, it helps us manage timing and dependencies through a sequence of calls.

2. The fundamental difference between 'success' and 'then' is that success will return the original promise instead of returning a new derived promise. Each then() invocation returns a fresh promise – which is key to chaining multiple promise calls.

详细差check here