我有一个方法,只有在我的forEach块完成执行后才需要调用它。现在在我的代码中,在我的forEach块被执行之后首先调用该函数。这是一段代码,
function processData(data) {
angular.forEach(data.ITINERARY.LIST_BOUNDS, function(bound, boundIndex) {
angular.forEach(bound.LIST_SEGMENT, function(segment, index) {
$q.all([
ServiceLocationAssistant.getAirport(segment.ORIGIN.LOCATION_CODE),
ServiceLocationAssistant.getAirport(segment.DESTINATION.LOCATION_CODE)
])
.then(function(locations) {
segment.ORIGIN.location = locations[0];
segment.DESTINATION.location = locations[1];
});
});
});
$scope.flightSection(processedData);//This method needs to be called
}