My code summary
I want if I click on "go back content", I return at the content tabs 1;
<mat-tab-group mat-stretch-tabs>
<mat-tab label="content 1">
........
</mat-tab>
<mat-tab label="content 2">
<button mat-raised-button (click)=""> go Back content 1</button>
</mat-tab>
</mat-tab-group>
You can bind the current selected tab's index to a variable and then set that variable when needed, like this:
<mat-tab-group mat-stretch-tabs [selectedIndex]="selectedIndex">
<mat-tab label="content 1">
........
</mat-tab>
<mat-tab label="content 2">
<button mat-raised-button (click)="selectedIndex = 0"> go Back content 1</button>
</mat-tab>
</mat-tab-group>
You can read more here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With