From 695911ad56ac6ce87e521df42e0f17d924b35d3e Mon Sep 17 00:00:00 2001 From: rhenck <richard.henck@iqb.hu-berlin.de> Date: Wed, 28 Jul 2021 18:09:44 +0200 Subject: [PATCH] Update form element value on init --- projects/common/form-element-component.directive.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/common/form-element-component.directive.ts b/projects/common/form-element-component.directive.ts index 90efb4720..51318d0e3 100644 --- a/projects/common/form-element-component.directive.ts +++ b/projects/common/form-element-component.directive.ts @@ -9,6 +9,7 @@ import { pairwise, startWith, takeUntil } from 'rxjs/operators'; import { FormService } from './form.service'; import { ValueChangeElement } from './form'; import { ElementComponent } from './element-component.directive'; +import { InputUIElement } from './unit'; @Directive() export abstract class FormElementComponent extends ElementComponent implements OnInit, OnDestroy { @@ -29,6 +30,7 @@ export abstract class FormElementComponent extends ElementComponent implements O formGroup: this.parentForm }); this.elementFormControl = this.formControl; + this.updateFormValue((this.elementModel as InputUIElement).value); this.elementFormControl.valueChanges .pipe( startWith(this.elementModel.value), @@ -49,7 +51,7 @@ export abstract class FormElementComponent extends ElementComponent implements O new FormControl({}); } - updateFormValue(newValue: string | number | boolean): void { + updateFormValue(newValue: string | number | boolean | undefined): void { this.elementFormControl?.setValue(newValue, { emitEvent: false }); } -- GitLab