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:

committed by
Jason Aden

parent
afb7540067
commit
883ca285de
@ -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);
|
||||
|
Reference in New Issue
Block a user