Hi Lucian,
Like Kier said, use $q.all()
do something like this:
/* @ngInject */
function testController(monitorService, $q) {
var vm = this;
vm.title = 'testController';
vm.checkStatus = checkStatus;
activate();
return;
////
function checkStatus() {
var orderedPromises = [];
var i;
for (i = 0; i < vm.serverList.length; i += 1){
orderedPromises.push(monitorService.getStatus(
vm.serverList[i]));
}
$q.all(orderedPromises).then(updateStatuses);
return;
function updateStatuses(orderedPromises) {
return orderedPromises.forEach(function (res, i) {
vm.serverList[i].receivedStatus = res;
});
}
}
function activate () {
checkStatus();
}
}
Regards
Sander
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.