2016-09-28 17 views

回答

0

您可以延遲加載多個@NMModules,其中每個模塊是一個單獨的應用程序。

compRef: ComponentRef<any>; 
constructor(private moduleLoader: SystemJsNgModuleLoader) { } 

this.moduleLoader.load(`/path/to/my/app`) 
    .then((moduleFactory: NgModuleFactory<any>) => { 
    const vcRef = this.vcRef; 
    const ngModuleRef = moduleFactory.create(vcRef.parentInjector); 
    const comp = ngModuleRef.injector.get(LazyLoadConfig).component; 
    const compFactory = ngModuleRef.componentFactoryResolver.resolveComponentFactory(comp); 
    this.compRef = vcRef.createComponent(compFactory, 0, ngModuleRef.injector); 
    }); 

查看this plunker的工作示例。