import { Component , createNgModuleRef , Injector , NgModule , ViewChild , ViewContainerRef } from '@angular/core' ; import { BrowserModule } from '@angular/platform-browser' ; import { SharedMfeModule } from '@angular-mfe/shared' ; @ Component ( { template : `
    <h1>Host MFE</h1>
    <ng-container #vc></ng-container>
  ` , selector : 'host-mfe' } ) export class HostMfeComponent { @ ViewChild ( 'vc' , { read : ViewContainerRef } ) vc : ViewContainerRef ; constructor ( readonly injector ) { ( < any > window ) . hostMfe = this ; } param path loadMfe ( path ) { import ( path ) . then ( mfe => this . vc . createComponent ( createNgModuleRef ( mfe . ngModule , this . injector ) . componentFactoryResolver . resolveComponentFactory ( mfe . EntryComponent ) ) ) ; } } @ NgModule ( { declarations : [ HostMfeComponent ] , imports : [ BrowserModule , SharedMfeModule ] , bootstrap : [ HostMfeComponent ] } ) export class ModuleMfeModule { }