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,14 +17,19 @@ export class ProgressBarComponent implements OnInit {
private value: number = 0; private value: number = 0;
ngOnInit() { ngOnInit() {
this.calculateValueForProgressbar()
this.formGroup this.formGroup
.valueChanges .valueChanges
.subscribe(control => { .subscribe(control => {
this.calculateValueForProgressbar();
});
}
calculateValueForProgressbar(){
var progressSoFar = this.countFormControlsWithValue(this.formGroup); var progressSoFar = this.countFormControlsWithValue(this.formGroup);
var total = this.getFormControlDepthLength(this.formGroup); var total = this.getFormControlDepthLength(this.formGroup);
var perc = (progressSoFar / total) * 100; var perc = (progressSoFar / total) * 100;
this.value = Number.parseFloat(perc.toPrecision(this.accuracy)); this.value = Number.parseFloat(perc.toPrecision(this.accuracy));
});
} }
countFormControlsWithValue(form: FormGroup): number { countFormControlsWithValue(form: FormGroup): number {