Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import("path-to-module/hello.module.js").then((module: any) => {
  2. this.compiler.compileModuleAndAllComponentsAsync(module.HelloModule)
  3. .then((compiled) => {
  4.  
  5. const helloModule = compiled.ngModuleFactory.create(this.injector);
  6. const componentFactory = compiled.componentFactories.find((factory: ComponentFactory<any>) => {
  7. return factory.componentType.name === "HelloMainComponent";
  8. });
  9. const helloComponent: ComponentRef<any> =
  10. componentFactory.create(this.injector, [], null, helloModule);
  11.  
  12. helloComponent.instance.lazyLoaded = true;
  13. helloComponent.instance.inputProp = "hello world"
  14.  
  15.  
  16. this.container.insert(helloComponent.hostView); // ViewContainerRef
  17. this.cd.markForCheck();
  18. });
  19. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement