Max Koretskyi
Max Koretskyi

Reputation: 105547

$q.all returns state instead of values - why

Here is the code:

$q.all($q.when(3), $q.when(5)).then(function (values) {
    console.log(values);
});

The output is the following:

{"$$state":{"status":1,"value":3}}

The manual states that:

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.

So I'm confused why values are not returned.

Upvotes: 2

Views: 536

Answers (1)

Martijn Welker
Martijn Welker

Reputation: 5605

$q.all accepts an array or an object, so if you change it to this it should work:

$q.all([$q.when(3), $q.when(5)]).then(function (values) {
    console.log(values);
});

Upvotes: 6

Related Questions