Install it with npm
npm install ngx-progressbar --save
Import NgProgressModule in the root module
import { NgProgressModule } from 'ngx-progressbar';
@NgModule({
imports: [
NgProgressModule
]
})
In your template
<ng-progress></ng-progress>
Add NgProgress service wherever you want to use the progressbar.
So you can modify your above code as below:
import { Component, Input } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { CompanyNameService } from '../services/company-name-service';
import { NgProgress } from 'ngx-progressbar';
@Component({
selector: 'app-financial-main',
templateUrl: './main-financial.html',
})
export class MainFinancialComponent {
@Input() CompanyID: number;
CompanyName: string = "";
CompanyLogo: string = "";
constructor(private route: ActivatedRoute, private companyNameService: CompanyNameService, public ngProgress: NgProgress) { }
ngOnInit() {
this.ngProgress.start();
this.route.params.subscribe(params => {
this.CompanyID = params['CompanyID'];
this.companyNameService.GetCompanyName(this.CompanyID).subscribe((data: []) => {
if (data.toString() != '[]') {
this.CompanyName = JSON.parse(data.toString())[0].DisplayName;
this.CompanyLogo = JSON.parse(data.toString())[0].LogoSourceUrl;
}
this.ngProgress.done();
});
});
}
}
And in your HTML template use this:
<ng-progress [positionUsing]="'marginLeft'" [minimum]="0.15" [maximum]="1"
[speed]="200" [showSpinner]="false" [direction]="'rightToLeftIncreased'"
[color]="'red'" [trickleSpeed]="250" [thick]="false" [ease]="'linear'"
></ng-progress>