Form field change detection

This commit is contained in:
Adina Țeudan 2022-07-22 01:13:43 +03:00
parent 6d9c169b3e
commit bdf3fc87ed

View File

@ -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<I> 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<I> implements ControlValueAccessor, Val
writeValue(option: I): void {
this._value = option;
this._changeRef.markForCheck();
}
validate(): ValidationErrors | null {