$q.all returns 状态而不是值 - 为什么
$q.all returns state instead of values - why
代码如下:
$q.all($q.when(3), $q.when(5)).then(function (values) {
console.log(values);
});
输出如下:
{"$$state":{"status":1,"value":3}}
手册指出:
Returns a single promise that will be resolved with an array/hash of
values, each value corresponding to the promise at the same index/key
in the promises array/hash. If any of the promises is resolved with a
rejection, this resulting promise will be rejected with the same
rejection value.
所以我很困惑为什么没有返回值。
$q.all
accepts an array or an object,所以如果你把它改成这样它应该可以工作:
$q.all([$q.when(3), $q.when(5)]).then(function (values) {
console.log(values);
});
代码如下:
$q.all($q.when(3), $q.when(5)).then(function (values) {
console.log(values);
});
输出如下:
{"$$state":{"status":1,"value":3}}
手册指出:
Returns a single promise that will be resolved with an array/hash of values, each value corresponding to the promise at the same index/key in the promises array/hash. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value.
所以我很困惑为什么没有返回值。
$q.all
accepts an array or an object,所以如果你把它改成这样它应该可以工作:
$q.all([$q.when(3), $q.when(5)]).then(function (values) {
console.log(values);
});