$http "then", $http
$http({...})
.then(function() {
return $http({...});
})
.then(function() {
return $http({...});
});
, $http . "", "" , , , ajax.
: :
var requests = [
{'url':'call1','method':'get'},
{'url':'call2','method':'get'},
{'url':'call3','method':'get'}
];
var promise = null;
angular.forEach(requests, function(details) {
promise = $q.when(promise).then(function() {
return $http(details);
});
});
Plunker http://plnkr.co/edit/RSMN8WuPOpvdCujtrrZZ?p=preview. $q.when , promise null, then, .