How do I sequentially chain promises with angularjs $q?

前端 未结 7 2245
一向
一向 2020-11-30 07:39

In the promise library Q, you can do the following to sequentially chain promises:

var items = [\'one\', \'two\', \'three\'];
var chain = Q();
items         


        
7条回答
  •  天命终不由人
    2020-11-30 08:22

    In perhaps a simpler manner than redgeoff's answer, if you don't need it automated, you can chain promises using $q.when() combined with .then() as shown in the beginning of this post. return $q.when() .then(function(){ return promise1; }) .then(function(){ return promise2; });

提交回复
热议问题