app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
isTaskRunning:boolean = false;
message:string = "The task is not run yet."
runTask(){
this.isTaskRunning = true;
this.message = "Task is running now."
// Do the task here
this.delay(10).then(()=>{
this.isTaskRunning = false;
this.message = "Task is finished."
}
);
}
delay(seconds:number) {
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
}
}
app.component.html
<h2 style="padding-top:25px; padding-bottom:25px;">
Angular Material - How to use Progress spinner
</h2>
<h4 style="margin-bottom:25px;">
{{message}}
</h4>
<button
mat-raised-button color="primary"
[disabled]="isTaskRunning"
style="margin-bottom:25px;"
(click)="runTask()">
Run Task
</button>
<mat-progress-spinner
mode="indeterminate" *ngIf="isTaskRunning">
</mat-progress-spinner>
app.module.ts [import]
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'
import {MatButtonModule} from '@angular/material/button'
- angular material - How to change Divider width
- angular material - How to change Divider thickness
- angular material - How to change vertical Divider height
- angular material - How to change Divider margin
- 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 - Determine an Expansion Panel is opened or closed
- angular material - Determine an Expansion Panel is disabled or enabled
- angular material - How to toggle Expansion Panel expanded state
- angular material - Initially expand a panel in Accordion
- angular material - Expansion Panel expandedChange event
- angular material - How to change Expansion Panel header height
- angular material - Action list with button and icon
- angular material - How to use Selection List