Skip to content

Commit

Permalink
fix(angular): router compatibility with Angular 12/13 (#25456)
Browse files Browse the repository at this point in the history
Resolves #25448
  • Loading branch information
sean-perkins committed Jun 13, 2022
1 parent afadf19 commit 7b105a3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions angular/src/directives/navigation/ion-router-outlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 7b105a3

Please sign in to comment.