I have:
<md-tab-group color="primary">
<md-tab label="Проэкты">
<h1>Some tab content</h1>
</md-tab>
<md-tab label="Обучалка">
<h1>Some more tab content</h1>
<p>...</p>
</md-tab>
</md-tab-group>
I need to catch an event when a specific tab is clicked and call this function inside my component:
onLinkClick() {
this.router.navigate(['contacts']);
}
You could use the (selectedTabChange)
event. Check Material2#tabs.
Template:
<mat-tab-group color="primary" (selectedTabChange)="onLinkClick($event)"> ... </mat-tab-group>
Component:
import { MatTabChangeEvent } from '@angular/material'; // ... onLinkClick(event: MatTabChangeEvent) { console.log({ event }); this.router.navigate(['contacts']); }
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