选项卡内的垫选项卡所选索引不起作用 [英] mat tab inside tab selected index not working
问题描述
When tab inside tab then if selected index of sub tab is 1 then it should show as selected.
When tab inside tab then if selected index of sub tab is 1 then it should show as selected.
让父标签有两个标签,它的 selectedIndex
为 0,父 tab1 内的子标签有 selectedIndex
= 1 然后里面的内容显示但不显示为被选中.选项卡内容显示但未选择选项卡
Let parent tab has two tabs, it has selectedIndex
is 0, and sub tab inside parent tab1 has selectedIndex
= 1 then content inside it showing but is not showing as selected. Tab content is showing but tab is not selected
这是有效的示例一>
Here is the working example
推荐答案
目前有一个 未解决的问题 为此.作为一种解决方法,您可以在父选项卡 selectedIndex
上使用 2 向绑定,然后仅在选择父选项卡时显示子选项卡组:
There is currently an open issue for this. As a workaround you can use 2 way binding on your parent tab selectedIndex
and then only show the subtab group when the parent tab is selected:
<mat-tab-group [(selectedIndex)]="index">
<mat-tab label="Tab 1">Parent tab 1 Content</mat-tab>
<mat-tab label="Tab 2">
<mat-tab-group *ngIf="index == 1" [selectedIndex]="1">
<mat-tab label="Tab 1">sub tab 1 Content </mat-tab>
<mat-tab label="Tab 2">sub tab 2 Content
</mat-tab>
</mat-tab-group>
</mat-tab>
</mat-tab-group>
这篇关于选项卡内的垫选项卡所选索引不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!