FieldState
Contains all of the state (e.g. value, statuses, etc.) associated with a Field
, exposed as
signals.
value
WritableSignal<TValue>
A writable signal containing the value for this field. Updating this signal will update the data model that the field is bound to.
touched
Signal<boolean>
A signal indicating whether the field has been touched by the user.
dirty
Signal<boolean>
A signal indicating whether field value has been changed by user.
disabled
Signal<boolean>
A signal indicating whether the field is currently disabled.
disabledReasons
Signal<readonly DisabledReason[]>
A signal containing the reasons why the field is currently disabled.
readonly
Signal<boolean>
A signal indicating whether the field is currently readonly.
errors
Signal<ValidationError[]>
A signal containing the current errors for the field.
errorSummary
Signal<ValidationError[]>
A signal containing the errors
of the field and its descendants.
valid
Signal<boolean>
A signal indicating whether the field's value is currently valid.
Note: valid()
is not the same as !invalid()
.
valid()
istrue
when there are no validation errors and no pending validators.invalid()
istrue
when there are validation errors, regardless of pending validators.
Ex: consider the situation where a field has 3 validators, 2 of which have no errors and 1 of
which is still pending. In this case valid()
is false
because of the pending validator.
However invalid()
is also false
because there are no errors.
invalid
Signal<boolean>
A signal indicating whether the field's value is currently invalid.
Note: invalid()
is not the same as !valid()
.
invalid()
istrue
when there are validation errors, regardless of pending validators.valid()
istrue
when there are no validation errors and no pending validators.
Ex: consider the situation where a field has 3 validators, 2 of which have no errors and 1 of
which is still pending. In this case invalid()
is false
because there are no errors.
However valid()
is also false
because of the pending validator.
pending
Signal<boolean>
Whether there are any validators still pending for this field.
submitting
Signal<boolean>
A signal indicating whether the field is currently in the process of being submitted.
name
Signal<string>
A signal of a unique name for the field, by default based on the name of its parent field.
keyInParent
Signal<TKey>
The property key in the parent field under which this field is stored. If the parent field is array-valued, for example, this is the index of this field in that array.
controls
Signal<readonly Control<unknown>[]>
A signal containing the Control
directives this field is currently bound to.
property
M | undefined
Reads a property value from the field.
M | undefined
hasProperty
boolean
Checks whether the given metadata key has been defined for this field.
boolean
markAsTouched
void
Sets the touched status of the field to true
.
void
markAsDirty
void
Sets the dirty status of the field to true
.
void