-
-
Notifications
You must be signed in to change notification settings - Fork 103
Usage
Murhaf Sousli edited this page Jan 10, 2020
·
19 revisions
NPM
npm i -S @ngx-progressbar/core
YARN
yarn add @ngx-progressbar/core
Import NgProgressModule
import { NgProgressModule } from '@ngx-progressbar/core';
@NgModule({
imports: [
NgProgressModule
]
})
You can set global config for all progress bars using
NgProgressModule.withConfig(config)
.
After you imported NgProgressModule
, you can now use the component <ng-progress>
and there are 3 ways to use the progress bar:
<ng-progress #progressBar></ng-progress>
<button (click)="progressBar.start()">Start</button>
<button (click)="progressBar.complete()">Complete</button>
@Component({
selector: 'app-home',
template: `
<ng-progress></ng-progress>
`
})
export class HomeComponent implements AfterViewInit {
@ViewChild(NgProgressComponent) progressBar: NgProgressComponent;
ngAfterViewInit() {
this.progressBar.start();
}
}
@Component({
selector: 'app-home',
template: `
<ng-progress id="myProgress"></ng-progress>
`
})
export class HomeComponent {
progressRef: NgProgressRef;
constructor(private progress: NgProgress) {
}
ngOnInit() {
this.progressRef = progress.ref('myProgress');
}
startLoading() {
this.progressRef.start();
}
completeLoading() {
this.progressRef.complete();
}
changeProgressColor() {
this.progressRef.setConfig({ color: 'green' });
}
}
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