Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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

enter image description here

Here is the working example

like image 320
Saurabh Agrawal Avatar asked Dec 23 '17 08:12

Saurabh Agrawal


1 Answers

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>

Demo

like image 125
Michael Doye Avatar answered Oct 17 '22 01:10

Michael Doye