From 8acf7d1befa9a18cd1c385e32999230b86be1ada Mon Sep 17 00:00:00 2001 From: Emirhan Aksoy <53901858+EmirhanAksoy@users.noreply.github.com> Date: Wed, 28 Sep 2022 19:00:24 +0300 Subject: [PATCH] Deprecated ComponentFactoryResolver removed --- .../flights-search/flights-search.component.ts | 18 +++++++++--------- .../bookings-search.component.ts | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/projects/mfe1/src/app/flights/flights-search/flights-search.component.ts b/projects/mfe1/src/app/flights/flights-search/flights-search.component.ts index d233251..b94a186 100644 --- a/projects/mfe1/src/app/flights/flights-search/flights-search.component.ts +++ b/projects/mfe1/src/app/flights/flights-search/flights-search.component.ts @@ -1,4 +1,5 @@ -import {Component, ViewChild, ViewContainerRef, Inject, Injector, ComponentFactoryResolver, OnInit} from '@angular/core'; +import {Component, ViewChild, ViewContainerRef, Inject, Injector} from '@angular/core'; +import { LazyComponent } from '../lazy/lazy.component'; @Component({ @@ -7,22 +8,21 @@ import {Component, ViewChild, ViewContainerRef, Inject, Injector, ComponentFacto }) export class FlightsSearchComponent { - @ViewChild('vc', { read: ViewContainerRef, static: true }) - viewContainer: ViewContainerRef; + @ViewChild('vc', { read: ViewContainerRef, static: true }) viewContainer!: ViewContainerRef; constructor( - @Inject(Injector) private injector, - @Inject(ComponentFactoryResolver) private cfr) { } + @Inject(Injector) private injector:Injector) { } search() { alert('Not implemented for this demo!'); } - async terms() { - const comp = await import('../lazy/lazy.component').then(m => m.LazyComponent); + terms() : void { - const factory = this.cfr.resolveComponentFactory(comp); - this.viewContainer.createComponent(factory, null, this.injector); + this.viewContainer.createComponent(LazyComponent,{ + index: 0, + injector : this.injector + }) } diff --git a/projects/mfe2/src/app/bookings/bookings-search/bookings-search.component.ts b/projects/mfe2/src/app/bookings/bookings-search/bookings-search.component.ts index d4451ad..62f262f 100644 --- a/projects/mfe2/src/app/bookings/bookings-search/bookings-search.component.ts +++ b/projects/mfe2/src/app/bookings/bookings-search/bookings-search.component.ts @@ -1,4 +1,5 @@ -import {Component, ViewChild, ViewContainerRef, Inject, Injector, ComponentFactoryResolver, OnInit} from '@angular/core'; +import {Component, ViewChild, ViewContainerRef, Inject, Injector} from '@angular/core'; +import { LazyComponent } from '../lazy/lazy.component'; @Component({ selector: 'app-bookings-search', @@ -6,22 +7,21 @@ import {Component, ViewChild, ViewContainerRef, Inject, Injector, ComponentFacto }) export class BookingsSearchComponent { - @ViewChild('vc', { read: ViewContainerRef, static: true }) - viewContainer: ViewContainerRef; + @ViewChild('vc', { read: ViewContainerRef, static: true }) viewContainer!: ViewContainerRef; constructor( - @Inject(Injector) private injector, - @Inject(ComponentFactoryResolver) private cfr) { } + @Inject(Injector) private injector:Injector) { } search() { alert('Not implemented for this demo!'); } - async terms() { - const comp = await import('../lazy/lazy.component').then(m => m.LazyComponent); + terms() : void { - const factory = this.cfr.resolveComponentFactory(comp); - this.viewContainer.createComponent(factory, null, this.injector); + this.viewContainer.createComponent(LazyComponent,{ + index: 0, + injector : this.injector + }) }