app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
counter: number = 0;
updateCounter(){
this.counter++;
}
}
app.component.html
<h2>Angular Material - How to use FAB</h2>
<h1>{{counter}}</h1>
<div style="display:flex; justify-content:space-between;
padding:20px;">
<button mat-fab (click)="updateCounter()"
aria-label="Basic material fab">
<mat-icon>cancel</mat-icon>
</button>
<button mat-fab color="primary" (click)="updateCounter()"
aria-label="Primary color fab">
<mat-icon>delete</mat-icon>
</button>
<button mat-fab color="accent" (click)="updateCounter()"
aria-label="Accent color fab">
<mat-icon>grade</mat-icon>
</button>
<button mat-fab color="warn" (click)="updateCounter()"
aria-label="Warn color fab">
<mat-icon>download</mat-icon>
</button>
</div>
<div style="display:flex; justify-content:space-between;
padding:20px; background-color:gray;">
<button mat-fab disabled (click)="updateCounter()"
aria-label="Disabled fab">
<mat-icon>zoom_in</mat-icon>
</button>
</div>
app.module.ts [import]
// for material button
import {MatButtonModule} from '@angular/material/button';
// for material icon
import {MatIconModule} from '@angular/material/icon';
- angular bootstrap - Show multiple months in a Datepicker
- angular bootstrap - Select date range in a Datepicker
- angular bootstrap - Select date range from Datepicker popup
- angular bootstrap - How to show footer in Datepicker
- angular bootstrap - Datepicker popup position & target
- angular bootstrap - How to collapse Accordion all panels
- angular bootstrap - Accordion panel custom header
- angular bootstrap - How to use Nav without ul li
- angular bootstrap - How to show vertical pills in a Nav
- angular material - How to use basic Button
- angular material - How to use raised Button
- angular material - How to use mini FAB
- angular material - How to use Button toggle
- angular material - How to use Button toggle group
- angular material - Button toggle group multiple selection