我想知道是否可以访问
ng-template
使用模板引用变量?
我尝试过使用@viewchild和@contentchild,但它们似乎都不起作用。
示例:我想访问app common的内容
<ng-template #first>
<app-common #second><app-common>
</ng-template>
@ViewChild('second') second1: ElementRef;
@ContentChild('second') second2: ElementRef;
ngAfterViewInit() {
console.log(this.second1);
}
ngAfterContentInit() {
console.log(this.second2);
}