$scope.listDocuments;
$scope.promises[];
angular.forEach(values, function($scope.listDocuments, document) {
promises.push(myService.downloadDocument(document.url).then(function(document)
{
console.debug(
document.name);
}).catch(error)
{
console.debug(
document.name);
});
}
$q.all(promises);
}
myService.downloadDocument{
var deferred = $q.defer();
$http
.get('
http://download/document')
.then(function(response) {
deferred.resolve(response.data);
}).catch(function(error) {
deferred.reject(err);
});
}
the problem is , i have service to download many documents, but when a document is failure i want to recover his name in catch console.debug(
document.name) i recover only last document in list not document that are failure. I think , the problem is not in service but in how i call service in foreach.
have you any idea..?