Skip to content

Commit 7b105a3

Browse files
authored
fix(angular): router compatibility with Angular 12/13 (#25456)
Resolves #25448
1 parent afadf19 commit 7b105a3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

angular/src/directives/navigation/ion-router-outlet.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
8989
private config: Config,
9090
private navCtrl: NavController,
9191
@Optional() private environmentInjector: EnvironmentInjector,
92+
@Optional() private componentFactoryResolver: ComponentFactoryResolver,
9293
commonLocation: Location,
9394
elementRef: ElementRef,
9495
router: Router,
@@ -243,6 +244,12 @@ export class IonRouterOutlet implements OnDestroy, OnInit {
243244

244245
const injector = new OutletInjector(activatedRouteProxy, childContexts, this.location.injector);
245246

247+
/**
248+
* The resolver is not always provided and is required in < Angular 14.
249+
* Fallback to the class-level provider when the resolver is not set.
250+
*/
251+
resolverOrInjector = resolverOrInjector || this.componentFactoryResolver;
252+
246253
if (resolverOrInjector && isComponentFactoryResolver(resolverOrInjector)) {
247254
// Backwards compatibility for Angular 13 and lower
248255
const factory = resolverOrInjector.resolveComponentFactory(component);

0 commit comments

Comments
 (0)