fixed progress bar not starting onInit

This commit is contained in:
annabakouli 2017-12-12 14:12:13 +02:00
parent bbb046656c
commit 62b3fc2185
1 changed files with 9 additions and 4 deletions

View File

@ -17,16 +17,21 @@ export class ProgressBarComponent implements OnInit {
private value: number = 0;
ngOnInit() {
this.calculateValueForProgressbar()
this.formGroup
.valueChanges
.subscribe(control => {
var progressSoFar = this.countFormControlsWithValue(this.formGroup);
var total = this.getFormControlDepthLength(this.formGroup);
var perc = (progressSoFar / total) * 100;
this.value = Number.parseFloat(perc.toPrecision(this.accuracy));
this.calculateValueForProgressbar();
});
}
calculateValueForProgressbar(){
var progressSoFar = this.countFormControlsWithValue(this.formGroup);
var total = this.getFormControlDepthLength(this.formGroup);
var perc = (progressSoFar / total) * 100;
this.value = Number.parseFloat(perc.toPrecision(this.accuracy));
}
countFormControlsWithValue(form: FormGroup): number {
let value = 0;
Object.keys(form.controls).forEach(key => {