Skip to content

Commit 883ca28

Browse files
vicbjasonaden
authored andcommitted
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.
1 parent afb7540 commit 883ca28

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/router/src/utils/collection.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ export function wrapIntoObservable<T>(value: T | NgModuleFactory<T>| Promise<T>|
9797
}
9898

9999
if (isPromise(value)) {
100-
return fromPromise(value);
100+
// Use `Promise.resolve()` to wrap promise-like instances.
101+
// Required ie when a Resolver returns a AngularJS `$q` promise to correctly trigger the
102+
// change detection.
103+
return fromPromise(Promise.resolve(value));
101104
}
102105

103106
return of (value);

0 commit comments

Comments
 (0)