Answer the question
In order to leave comments, you need to log in
How to correctly inject Promise dependency into $injector.invoke?
Good afternoon!
There is an object:
resolve = {
promise1: (MyService) => MyService.all(),
promise2: (MyService2, promise1) => { return promise1.then((data) => MyService2.getData(data.id))},
}
angular.forEach(resolve, function (value, key) {
resolve[key] = $injector.invoke(value, null, resolve, key);
});
$q.all({
...
locals: $q.all(resolve)
}).then(function (data) {
...
}
promise2: (MyService2, promise1) => MyService2.getData(promise1.id)
$q.all({
...
locals: $q.all(resolve)
}).then(function (data) {
resolve.promise2.then((item) => {
resolve.promise2 = item;
});
...
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question