2017-03-02 8 views
1

Ich plane Winkeljs Versprechen in meiner Anwendung zu verwenden. Aber ich bekomme keinen wirklichen Unterschied zwischen der .success Funktion und der .then Funktion.Ajax Erfolg Vs dann (Winkel Versprechen)

+0

möglicherweise Duplikat von http://stackoverflow.com/questions/16385278/angular-httppromise-difference-between-success- error-methods-and-thens-a –

+2

Mögliche Duplikate von [Angular HttpPromise: Unterschied zwischen \ 'success \ '/ \' error \ 'Methoden und \' then \ 's Argumente] (http://stackoverflow.com/ Fragen/16385278/angular-httppromise-Differenz zwischen Erfolgsermittlungsmethoden und -themen-a) –

Antwort

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.

für detaillierte Unterschied check here