How do I sequentially chain promises with angularjs $q?

前端 未结 7 2086
一向
一向 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:42

    Having this:

    let items = ['one', 'two', 'three'];
    

    One line (well, 3 for readability):

    return items
        .map(item => foo.bind(null, item))
        .reduce($q.when, $q.resolve());
    
    0 讨论(0)
提交回复
热议问题