Skip to main content

angular bootstrap - Progressbar maximum value

app.component.ts

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

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


export class AppComponent {
  isDisable:boolean = false;
  progress:number = 0;
  maxValue:number = 250;
  timer: any;

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

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

<h4 style="padding-top:25px; padding-bottom:25px;">
  Angular Bootstrap - Progressbar maximum value
</h4>

<button (click)="onClick()" [disabled]="isDisable">Run Task</button>
<br/><br/>

<h5>{{'Done '+ progress + ' of '+ maxValue}}</h5>
<br/>

<ngb-progressbar 
  type="success" 
  [value]="progress"
  [showValue]="true"
  [max]="maxValue">
</ngb-progressbar>
More Angular tutorials