From 2cee67db8a74d53289cf968e08b313e168ca1dff Mon Sep 17 00:00:00 2001 From: cipchk Date: Fri, 21 Jul 2023 18:45:28 +0800 Subject: [PATCH] fix(abc:onboarding): fix `ComponentFactoryResolver` --- packages/abc/onboarding/onboarding.service.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/abc/onboarding/onboarding.service.ts b/packages/abc/onboarding/onboarding.service.ts index 687c7921e..d1f9bbbca 100644 --- a/packages/abc/onboarding/onboarding.service.ts +++ b/packages/abc/onboarding/onboarding.service.ts @@ -2,14 +2,13 @@ import { Directionality } from '@angular/cdk/bidi'; import { DOCUMENT } from '@angular/common'; import { ApplicationRef, - ComponentFactoryResolver, ComponentRef, EmbeddedViewRef, Inject, Injectable, - Injector, OnDestroy, - Optional + Optional, + createComponent } from '@angular/core'; import { Router } from '@angular/router'; import { of, pipe, Subscription, delay, switchMap } from 'rxjs'; @@ -47,17 +46,17 @@ export class OnboardingService implements OnDestroy { constructor( private i18n: DelonLocaleService, private appRef: ApplicationRef, - // TODO: Tracking https://github.com/angular/angular/issues/45263 - private resolver: ComponentFactoryResolver, private router: Router, - private injector: Injector, @Inject(DOCUMENT) private doc: NzSafeAny, private configSrv: AlainConfigService, @Optional() private directionality: Directionality ) {} private attach(): void { - const compRef = (this.compRef = this.resolver.resolveComponentFactory(OnboardingComponent).create(this.injector)); + const compRef = createComponent(OnboardingComponent, { + environmentInjector: this.appRef.injector + }); + this.compRef = compRef; this.appRef.attachView(compRef.hostView); const compNode = (compRef.hostView as EmbeddedViewRef).rootNodes[0]; const doc = this._getDoc();