【发布时间】:2017-12-22 09:44:40
【问题描述】:
我开始学习 Angular 中的 DOM 操作,并注意到 templateRef 及其方法 createEmbeddedView。我更想了解这种方法。现在我的问题是,如何使用这个方法的createEmbeddedView
@Component({
selector: 'app-root',
template: `
<ng-template #template>
</ng-template>
`
})
export class AppComponent implements AfterViewChecked {
@ViewChild('template', { read: TemplateRef }) _template: TemplateRef<any>;
constructor() { }
ngAfterViewChecked() {
this._template.createEmbeddedView('this is a embedded view')
}
}
【问题讨论】: