mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
All components, directives and pipes will now use standalone as default. Non-standalone decorators have now . PR Close #58160
24 lines
689 B
TypeScript
24 lines
689 B
TypeScript
import {AfterViewInit, Compiler, Component, ViewChild, ViewContainerRef} from '@angular/core';
|
|
|
|
@Component({
|
|
selector: 'app-root',
|
|
template: `
|
|
<h1>Hello world!</h1>
|
|
<div #vc></div>
|
|
`,
|
|
standalone: false,
|
|
})
|
|
export class AppComponent implements AfterViewInit {
|
|
@ViewChild('vc', {read: ViewContainerRef}) container: ViewContainerRef;
|
|
|
|
constructor(private compiler: Compiler) {}
|
|
|
|
ngAfterViewInit() {
|
|
import('./lazy.module').then((module) => {
|
|
this.compiler.compileModuleAndAllComponentsAsync(module.LazyModule).then((compiled) => {
|
|
const factory = compiled.componentFactories[0];
|
|
this.container.createComponent(factory);
|
|
});
|
|
});
|
|
}
|
|
}
|