$q.all([promise]).then(function(data)){
console.log('resolved');
};
assume promise is 'undefined' when it will be resolved? even promise is null or undefined , it is getting resolved,So confused about $q behavior.Please could you clarify this.
$q.all
can, even if not documented, take plain values as well and not only promises - it will automatically convert them. So your code is equivalent to
$q.all([$q.when(promise)]).then(function(data)) {
console.log('resolved');
};
And if promise
is null
, you'll get a promise that is resolved with null
, which is why you will finally see [null]
in your data
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.