I'm trying to reset mat-tab-group
to set first tab as active when routeParams
changed.
ts file:
public index = 0;
ngOnInit() {
this.subscription = this.route.params.subscribe((routeParams: Params) => {
// some code
this.index = 0;
});
}
html file
<mat-tab-group [selectedIndex]="index">
<mat-tab></mat-tab>
<mat-tab>
<a [routerLink]="['/url/2']"></a>
</mat-tab>
In the second tab I have a router link to another card - so, when router navigates to this card component doesn't reloaded (route is /url/:id
).
But first tab doesn't become active - even if I set index inside subscription on route params.