mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 11:41:20 +08:00
fix(angular): router compatibility with Angular 12/13 (#25456)
Resolves #25448
This commit is contained in:
@ -89,6 +89,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
|
|||||||
private config: Config,
|
private config: Config,
|
||||||
private navCtrl: NavController,
|
private navCtrl: NavController,
|
||||||
@Optional() private environmentInjector: EnvironmentInjector,
|
@Optional() private environmentInjector: EnvironmentInjector,
|
||||||
|
@Optional() private componentFactoryResolver: ComponentFactoryResolver,
|
||||||
commonLocation: Location,
|
commonLocation: Location,
|
||||||
elementRef: ElementRef,
|
elementRef: ElementRef,
|
||||||
router: Router,
|
router: Router,
|
||||||
@ -243,6 +244,12 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
|
|||||||
|
|
||||||
const injector = new OutletInjector(activatedRouteProxy, childContexts, this.location.injector);
|
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)) {
|
if (resolverOrInjector && isComponentFactoryResolver(resolverOrInjector)) {
|
||||||
// Backwards compatibility for Angular 13 and lower
|
// Backwards compatibility for Angular 13 and lower
|
||||||
const factory = resolverOrInjector.resolveComponentFactory(component);
|
const factory = resolverOrInjector.resolveComponentFactory(component);
|
||||||
|
Reference in New Issue
Block a user