Just trying to understand how the $q.all()
works:
In my example, i use $q.all()
to execute 2 functions (both intentionally return reject()
), i expected the fail
handler in the then()
to get called, but it doesnt, why is this so?
Code:
var myApp = angular.module('myApp',[]);
function MyCtrl($scope,$q) {
f1 = function(){
return $q.defer().reject();
}
f2 = function(){
return $q.defer().reject();
}
s = function(){alert('success!'); };
f = function(){alert('failed!');};
$q.all([f1(),f2()]).then(s,f);
}
Fiddle:
http://jsfiddle.net/sajjansarkar/ADukg/10942/
EDIT :
I found the same code works if I make the functions return the raw promise and introduce a delay before rejecting it.