我想知道是否可以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);
}