5

I have a table while using in mat-tab , expandable row are getting expanded on switching tabs

https://stackblitz.com/edit/angular-yjgkst here is the link

2

2 Answers 2

6

Use <ng-template matTabContent> in the <mat-tab>

DEMO

Sign up to request clarification or add additional context in comments.

2 Comments

Can you explain why this is working please?
This is described in the documentation and it works
0

Use <ng-template matTabContent> in the <mat-tab> this is a solution, that changes the behaviour of each tab, with this template it lazy loads each tab, and whenever you click the tab, it does trigger ngOnInit... I wanted to keep the behaviour I have, I just wanted to remove the bug of expanding rows whenever I click another tab..

It worked for me! :) You can just wrap up your element (which has the table) with a div, e.g.:

 <mat-tab-group mat-align-tabs="start">
  <mat-tab label="First"><div><app-table-element-selector></app-table-element-selector></div></mat-tab>
  <mat-tab label="Second"><app-element2-selector></app-element2-selector></mat-tab>
  <mat-tab label="Third"><app-element3-selector></app-element3-selector></mat-tab>
</mat-tab-group>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.