From bdf3fc87ed52a13cf55175e0fd1a33e17dd0930c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adina=20=C8=9Aeudan?= Date: Fri, 22 Jul 2022 01:13:43 +0300 Subject: [PATCH] Form field change detection --- src/lib/inputs/form-field/form-field-component.directive.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/inputs/form-field/form-field-component.directive.ts b/src/lib/inputs/form-field/form-field-component.directive.ts index 08ae8e4..db7b09e 100644 --- a/src/lib/inputs/form-field/form-field-component.directive.ts +++ b/src/lib/inputs/form-field/form-field-component.directive.ts @@ -1,4 +1,4 @@ -import { Directive } from '@angular/core'; +import { ChangeDetectorRef, Directive, inject } from '@angular/core'; import { ControlValueAccessor, ValidationErrors, Validator } from '@angular/forms'; @Directive() @@ -6,6 +6,8 @@ export abstract class FormFieldComponent implements ControlValueAccessor, Val touched = false; disabled = false; + protected readonly _changeRef = inject(ChangeDetectorRef); + protected _value: I | undefined; get value(): I | undefined { @@ -38,6 +40,7 @@ export abstract class FormFieldComponent implements ControlValueAccessor, Val writeValue(option: I): void { this._value = option; + this._changeRef.markForCheck(); } validate(): ValidationErrors | null {