app.component.ts
import { Component } from '@angular/core';
import { MatTabGroup } from '@angular/material/tabs';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
message:string = "";
logTabChange(tabs:MatTabGroup){
tabs.selectedIndex
this.message = "Tab selection changed. Selected index is : "
+ tabs.selectedIndex
}
}
app.component.html
<h2 style="padding-top:25px; padding-bottom:25px;">
Angular Material - How to use Tabs selectedTabChange event
</h2>
<h3>{{message}}</h3>
<mat-tab-group #tabs (selectedTabChange)="logTabChange(tabs)">
<mat-tab label="Flash">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Nam tincidunt elit non molestie rutrum.
Donec blandit risus et sem iaculis aliquam.
</mat-tab>
<mat-tab label="Dreamweaver">
Cras feugiat pharetra dolor, ac euismod tellus maximus eu.
Etiam dignissim enim vel lacus molestie, in iaculis tellus
ultrices.
</mat-tab>
<mat-tab label="Photoshop">
Integer rhoncus tristique felis ut dignissim.
</mat-tab>
</mat-tab-group>
app.module.ts [import]
import { MatTabsModule } from '@angular/material/tabs'
- angular material - Button toggle group initially checked items
- angular material - How to show Tooltip
- angular material - How to set Tooltip show hide delay
- angular material - How to enable disable Tooltip
- angular material - How to use indeterminate Progress spinner
- angular - How to use setTimeout()
- angular material - How to change Progress spinner color
- angular material - How to center Progress spinner
- angular material - How to align Tabs
- angular material - How to disable Tabs content animation
- angular material - How to slow Tabs content transition
- angular material - How to get Tabs selected index
- angular material - How to delete Tab programmatically
- angular material - How to show remove button on Tab label
- angular material - How to show Tab label bottom of content