Angular 5:createComponent未定义

时间:2019-01-04 07:12:28

标签: angular angular5

几乎已经检查并测试了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);


    }

请帮帮我!

0 个答案:

没有答案