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