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
setTimeout(()=>{
this.isTaskRunning = false;
this.message = "Task is finished.";
},10000);
}
}
app.component.html
<h2 style="padding-top:25px; padding-bottom:25px;">
Angular Material - How to use indeterminate Progress spinner
</h2>
<h4 style="margin-bottom:20px;">
{{message}}
</h4>
<button
mat-raised-button color="primary"
[disabled]="isTaskRunning"
style="margin-bottom:20px;"
(click)="runTask()">
Run Task
</button>
<mat-progress-spinner
mode="indeterminate"
*ngIf="isTaskRunning"
color="warn">
</mat-progress-spinner>
app.module.ts [import]
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner'
import {MatButtonModule} from '@angular/material/button'
- angular material - Button toggle group initially checked items
- angular material - How to show Tooltip
- angular material - Show Tooltip on a specific position
- angular material - How to show vertical Divider
- angular material - How to use Progress bar
- angular material - How to use query Progress bar
- angular material - Percentage in determinate Progress bar
- angular - How to use clearInterval()
- angular material - Show custom color in Progress bar
- angular material - How to change Divider width
- angular material - How to change Divider thickness
- angular - How to use setTimeout()
- angular material - How to use determinate Progress spinner
- angular material - Progress spinner with percentage
- angular material - How to change Progress spinner size