How do I sequentially chain promises with angularjs $q?

前端 未结 7 2200
一向
一向 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:29

    var when = $q.when();
    
    for(var i = 0; i < 10; i++){
        (function() {
             chain = when.then(function() {
            return $http.get('/data');
          });
    
        })(i); 
    }
    

提交回复
热议问题