import { Component , Input , Compiler , Injector , ViewChild , ViewContainerRef , ChangeDetectorRef , } from '@angular/core' ; @ Component ( { selector : 'm-channelShop__lazy' , template : `
    <ng-template #anchor></ng-template>
  ` , } ) export class ChannelShopLazyComponent { @ Input ( ) component : string ; @ ViewChild ( 'anchor' , { read : ViewContainerRef } ) anchor : ViewContainerRef ; constructor ( private compiler , private injector , private cd ) { } ngOnInit ( ) { this . loadComponent ( ) ; } async loadComponent ( ) { const { ChannelsShopModule } = await import ( './shop.module' ) ; const moduleFactory = await this . compiler . compileModuleAsync ( ChannelsShopModule ) ; const moduleRef = moduleFactory . create ( this . injector ) ; const componentFactories = moduleRef . instance . resolveComponents ( ) ; const componentFactory = componentFactories [ this . component ] ; this . anchor . clear ( ) ; this . anchor . createComponent ( componentFactory ) ; this . cd . markForCheck ( ) ; this . cd . detectChanges ( ) ; } }