Skip to main content

angular bootstrap - How to use Progressbar

app.component.ts

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})


export class AppComponent {
  progress:number = 0;
  timer: any;

  onClick(){
    this.progress = 0;
    this.timer = setInterval(() => this.updateProgress(), 300)
  }

  updateProgress(){
    this.progress++
    if(this.progress>=100)
    {
      clearInterval(this.timer);
    }
  }
}
app.component.html

<h4 style="padding-top:25px; padding-bottom:25px;">
  Angular Bootstrap - How to use Progressbar
</h4>


<button (click)="onClick()">Run Task</button>
<br/><br/>

<h5>Progress : {{progress+'%'}}</h5>

<p>
  <ngb-progressbar type="success" [value]="progress">
  </ngb-progressbar>
</p>
More Angular tutorials