app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
tabs = ["SQL","PHP","Photoshop"];
deleteTab(index:number){
this.tabs.splice(index,1);
}
}
app.component.html
<h2 style="padding-top:25px; padding-bottom:25px;">
Angular Material - How to show remove button on Tab label
</h2>
<h3>Selected Tab Index : {{tabGroup.selectedIndex}}</h3>
<mat-tab-group
[selectedIndex]="0"
#tabGroup
style="margin-bottom:50px;">
<mat-tab *ngFor="let tab of tabs; let index = index">
<ng-template mat-tab-label>
<button
mat-icon-button
[disabled]="tabs.length === 1"
aria-label="delete icon button"
(click)="deleteTab(index)"
style="margin-right:8px;">
<mat-icon>close</mat-icon>
</button>
{{tab}}
</ng-template>
Content of {{tab}}
</mat-tab>
</mat-tab-group>
app.module.ts [import]
import { MatTabsModule } from '@angular/material/tabs'



- angular material - How to generate Tabs programmatically
- angular material - How to create & add Tab programmatically
- angular material - How to delete Tab programmatically
- angular material - How to show Tab label bottom of content
- angular material - How to use vertical Slider
- angular material - How to change Slider width
- angular material - Tick interval auto in Slider
- angular material - How to show thumb label in Slider
- angular material - Slider custom formatted thumb label
- angular material - How to use Slider change event
- angular material - How to get Slide toggle checked status
- angular material - How to change Slide toggle label position
- angular material - How to use Slide toggle change event
- angular material - How to use custom Badge size
- angular material - How to show custom color in Badge