2017-03-02 122 views
1

我打算在我的應用程序中使用angularjs promise。但是我沒有得到.success函數和.then函數之間的實際區別。Ajax成功vs然後(角度承諾)

+0

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

+2

[Angular HttpPromise:\'success \'/ \'error \'methods和\'然後\''參數之間的區別]的可能副本(http://stackoverflow.com/問題/ 16385278 /角httppromise差之間成功 - 誤差的方法和 - thens-a)的 –

回答

1

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