Kruno
Kruno

Reputation: 159

Can I display content of mat-tab only if I click on tab? Angular

So I want to display content only if I clicked on tab. Is it possible? The reason why I want to achieve this is because when I filter through tabs, content is loaded while I'm typing in filter input

Upvotes: 1

Views: 866

Answers (1)

Eliseo
Eliseo

Reputation: 57909

I dont like ::ng-deep, see the docs I always prefer create a class in styles.scss -or in styles.css-

.noFirst .mat-tab-labels:first-child > .mat-tab-label:first-child {
  display: none;
}

Then when I want, add the class to mat-tab-group

<mat-tab-group class="noFirst">
  <mat-tab></mat-tab>
  <mat-tab label="First"> Content 1 </mat-tab>
  ....
</mat-tab-group>

Upvotes: 1

Related Questions