fixed progress bar not starting onInit
This commit is contained in:
parent
bbb046656c
commit
62b3fc2185
dmp-frontend/src/app/form/pprogress-bar
|
@ -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 => {
|
||||||
|
|
Loading…
Reference in New Issue