-
-
Notifications
You must be signed in to change notification settings - Fork 101
Integration (legacy)
Murhaf Sousli edited this page Aug 18, 2024
·
1 revision
You can integrate any progress bar or spinner by subscribing to NgProgressRef.state
, here is an example of using Material progress bar
import { Component, OnInit, OnDestroy } from '@angular/core';
import { NgProgressModule, NgProgress, progressRef } from 'ngx-progressbar';
@Component({
selector: 'custom-progress-bar',
template: `
<ng-container *ngIf="progressRef.state | async as state">
<mat-progress-bar *ngIf="state.active" [value]="state.value"></mat-progress-bar>
</ng-container>
`,
standalone: true,
imports: [NgProgressModule]
})
export class CustomProgressBar implements OnInit, OnDestroy {
progressRef: NgProgressRef;
constructor(private ngProgress: NgProgress) {
}
ngOnInit() {
this.progressRef = this.ngProgress.ref();
// Progress bar actions (optional)
this.progressRef.start();
this.progressRef.complete();
this.progressRef.set();
this.progressRef.inc();
// Progress bar events (optional)
this.progressBar.started.subscribe(() => this.onStarted());
this.progressBar.completed.subscribe(() => this.onCompleted());
}
ngOnDestroy() {
// Destroy the progress bar ref
this.progressRef.destroy();
}
}
In this case you don't need to use <ng-progress>
in your template :)
Become a sponsor and get your logo on our README on GitHub and the front page of https://ngx-progressbar.netlify.com/.
Become a backer and get your logo on our README on GitHub.
Older version (v12)
-
Automagic features
Older version (v11)
-
Automagic features