I am using angular's $q
promise like this:
$scope.loadingData = true; // show loading spinner in view
var thingsToProcess = [....];
for(int i = 0; i < thingsToProcess.length; i++) {
var itemToProcess = thingsToProcess[i];
makeServiceCallThatReturnsPromise(itemToProcess)
.then(function(response) {
processAndDisplayResponse(response);
});
}
$loadingData = false; // hide loading spinner
Since the service call promises get queued, the loading indicator goes away before all the data is returned from the service.
How can I keep the loading flag set till all the promises are served?