fix(router): Wrap Promise-like instances in native Promises (#16759)

Hybrid apps (mix of Angular and AngularJS) might return AngularJS implementation
of Promises that do not play well with the change detection. Wrapping them in
native Promises fix this issue.

This could be the case when a Resolver returns a `$q` promise.
This commit is contained in:
Victor Berchet 2017-05-12 19:03:54 +02:00 committed by Jason Aden
parent b83fe6f2a4
commit 569b1e0eb7
1 changed files with 4 additions and 1 deletions

View File

@ -97,7 +97,10 @@ export function wrapIntoObservable<T>(value: T | NgModuleFactory<T>| Promise<T>|
}
if (isPromise(value)) {
return fromPromise(value);
// Use `Promise.resolve()` to wrap promise-like instances.
// Required ie when a Resolver returns a AngularJS `$q` promise to correctly trigger the
// change detection.
return fromPromise(Promise.resolve(value));
}
return of (value);