feat(platform-browser-dynamic): export JitCompilerFactory
(#20478)
Fixes #20125 PR Close #20478
This commit is contained in:

committed by
Miško Hevery

parent
437a0446e2
commit
d7a727cc07
27
integration/dynamic-compiler/src/app.component.ts
Normal file
27
integration/dynamic-compiler/src/app.component.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import {AfterViewInit, Compiler, Component, ViewChild, ViewContainerRef} from '@angular/core';
|
||||
|
||||
declare var System: any;
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
template: `
|
||||
<h1>Hello world!</h1>
|
||||
<div #vc></div>
|
||||
`,
|
||||
})
|
||||
export class AppComponent implements AfterViewInit {
|
||||
@ViewChild('vc', {read: ViewContainerRef}) container: ViewContainerRef;
|
||||
|
||||
constructor(private compiler: Compiler) {
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
System.import('./dist/lazy.bundle.js').then((module: any) => {
|
||||
this.compiler.compileModuleAndAllComponentsAsync(module.LazyModule)
|
||||
.then((compiled) => {
|
||||
const factory = compiled.componentFactories[0];
|
||||
this.container.createComponent(factory);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user