考虑一下我的模板中的这些材料选项卡:
<mat-tab #myFirstTab>Something</mat-tab>
<mat-tab #mySecondTab>Something else</mat-tab>和ViewChildren文件中的.ts:
@ViewChildren(MatTab)
private allTabs: QueryList<MatTab>;
public ngAfterViewInit() {
this.allTabs.forEach(tab => console.log('tab: ', tab));
}如何访问我的代码中每个选项卡 (#myFirstTab和#mySecondTab)的实际模板引用?这条路有可能吗?我需要一种区分标签的方法,标签文本不是很好,因为它可以改变.
编辑:,我专门要求“查看儿童”,而不是“查看儿童”。我当然知道相反的情况。在这种情况下,我不想在.ts文件中声明每个Viewchild。
发布于 2019-10-30 19:48:09
ViewChild指令?例如:
@ViewChild('myFirstTab') myFirstTab: MatTab;
@ViewChild('mySecondTab') mySecondTab: MatTab;https://stackoverflow.com/questions/58630810
复制相似问题