几乎已经检查并测试了stackoverflow中可用的所有内容。我遇到了同样的问题
HTML
<ng-template #target></ng-template>
ts
@ViewChild('target', {read: ViewContainerRef}) target;
ngAfterViewInit() {
const factory = this.componentFactoryResolver.resolveComponentFactory(MonthlyReportComponent);
const ref = this.target.createComponent(factory);
}
请帮帮我!