fix(angular): router compatibility with Angular 12/13 (#25456)

Resolves #25448
This commit is contained in:
Sean Perkins
2022-06-13 12:11:11 -04:00
committed by GitHub
parent afadf1940b
commit 7b105a3471

View File

@ -89,6 +89,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
private config: Config,
private navCtrl: NavController,
@Optional() private environmentInjector: EnvironmentInjector,
@Optional() private componentFactoryResolver: ComponentFactoryResolver,
commonLocation: Location,
elementRef: ElementRef,
router: Router,
@ -243,6 +244,12 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
const injector = new OutletInjector(activatedRouteProxy, childContexts, this.location.injector);
/**
* The resolver is not always provided and is required in < Angular 14.
* Fallback to the class-level provider when the resolver is not set.
*/
resolverOrInjector = resolverOrInjector || this.componentFactoryResolver;
if (resolverOrInjector && isComponentFactoryResolver(resolverOrInjector)) {
// Backwards compatibility for Angular 13 and lower
const factory = resolverOrInjector.resolveComponentFactory(component);