Form field change detection
This commit is contained in:
parent
6d9c169b3e
commit
bdf3fc87ed
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user