feat(platform-browser-dynamic): export JitCompilerFactory (#20478)

Fixes #20125
PR Close #20478
This commit is contained in:
Olivier Combe
2017-11-15 18:22:23 +01:00
committed by Miško Hevery
parent 437a0446e2
commit d7a727cc07
17 changed files with 280 additions and 0 deletions

View 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);
});
});
}
}