You need to enter the service $qand use the function$q.all
var stagesList = $http.get(apiURL).then(function(resdata, status, headers, config) {
return resdata;
})
.then(function(stagesData) {
stageId = stagesData.data.childStages;
var self = this;
return $q.all(
_.map(stageId, function(item) {
var stagesApiURL = "http://localhost:9080/stageDetails/" + item.stage.stageId;
return $http.get(stagesApiURL).then(function(taskData, status, headers, config) {
return taskData.data;
});
})
);
})
.then(function(allTasksData) {
console.log("Hello");
_.each(allTasksData, function(data) {
$scope.tasksData.concat(data);
});
});
: map each promises. promises $q.all, taskData.data .