From 62b3fc21857a93607f9ae7910ad8813eeac1ed5e Mon Sep 17 00:00:00 2001 From: annabakouli Date: Tue, 12 Dec 2017 14:12:13 +0200 Subject: [PATCH] fixed progress bar not starting onInit --- .../form/pprogress-bar/progress-bar.component.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/dmp-frontend/src/app/form/pprogress-bar/progress-bar.component.ts b/dmp-frontend/src/app/form/pprogress-bar/progress-bar.component.ts index 24de771ae..89ae3437b 100644 --- a/dmp-frontend/src/app/form/pprogress-bar/progress-bar.component.ts +++ b/dmp-frontend/src/app/form/pprogress-bar/progress-bar.component.ts @@ -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 => {