Skip to main content

angular bootstrap - Show custom label in Progressbar

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;
  timer: any;
  maxValue:number = 250;

  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 - Show custom label in Progressbar
</h4>

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

<ngb-progressbar 
  #progressbar
  type="info" [value]="progress" 
  [showValue]="false" [max]="maxValue" height="2rem">
    {{progress + ' of '+ maxValue +' done.'}}
</ngb-progressbar>
More Angular tutorials