app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
colors = ["Red","Green","Blue","Pink","Azure"];
message:string = "";
onClick(color:string){
this.message = color + " button clicked";
}
}
app.component.html
<h2 style="padding-top:25px; padding-bottom:16px;">
Angular Material - Navigation list with button and icon
</h2>
<h3>{{message}}</h3>
<mat-nav-list>
<mat-list-item *ngFor="let color of colors">
<a matLine href="#">
{{color}}
</a>
<button mat-icon-button (click)="onClick(color)">
<mat-icon>check_circle</mat-icon>
</button>
</mat-list-item>
</mat-nav-list>
app.module.ts [import]
import { MatListModule } from '@angular/material/list'
import { MatButtonModule } from '@angular/material/button'
import { MatIconModule } from '@angular/material/icon';
- angular - How to use clearInterval()
- angular material - Show custom color in Progress bar
- angular material - How to change Progress bar height
- angular material - How to use indeterminate Progress spinner
- angular - How to use setTimeout()
- angular material - How to use Accordion flat display mode
- angular material - Open & close Expansion Panel on button click
- angular material - Expansion Panel afterExpand & afterCollapse event
- angular material - How to initially expand Expansion Panel
- angular material - Expansion Panel header expanded background color
- angular material - Accordion expanded panels header background color
- angular material - How to use List dense layout mode
- angular material - How to use Navigation List
- angular material - How to use Action List
- angular material - Action list with button and icon