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
dmp-frontend/src/app/form/pprogress-bar

View File

@ -17,16 +17,21 @@ 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 => {
var progressSoFar = this.countFormControlsWithValue(this.formGroup); this.calculateValueForProgressbar();
var total = this.getFormControlDepthLength(this.formGroup);
var perc = (progressSoFar / total) * 100;
this.value = Number.parseFloat(perc.toPrecision(this.accuracy));
}); });
} }
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 { countFormControlsWithValue(form: FormGroup): number {
let value = 0; let value = 0;
Object.keys(form.controls).forEach(key => { Object.keys(form.controls).forEach(key => {