4
votes

I'm facing the following problem with mat-tab-group nested inside a mat-tab-group. The nested group in the first tab of the parent group is selecting a default tab and showing the underline in the first tab, but the group nested in the third tab of the parent group, it's not showing the underline in any tab.

I've attached the link of the demo with the problem: https://stackblitz.com/edit/angular-material-tabs-problem

Any help? Thanks in advance!

2
Thanks, that solved the issuePablo Sanchez
Does this answer your question? mat tab inside tab selected index not workingEdric

2 Answers

7
votes

As this post suggests https://github.com/angular/components/issues/7274#issuecomment-605516292 wrap your child mat-tab-group with a <ng-template matTabContent> and it'll work (tested with Angular 8).

<mat-tab-group>
  <mat-tab label="Tab1">
    Test1
  </mat-tab>
  <mat-tab label="Tab2" >
    <ng-template matTabContent>
      <mat-tab-group>
        <mat-tab label="Tab2-1">
          Test2-1
        </mat-tab>
        <mat-tab label="Tab2-2">
          Test2-2
        </mat-tab>
      </mat-tab-group>
    </ng-template>
  </mat-tab>
</mat-tab-group>
2
votes

After reviewing the mat tab inside tab selected index not working question, the workaround provided there solved the problem.