Contains all of the state (e.g. value, statuses, etc.) associated with a FieldTree
, exposed as
signals.
API
interface FieldState<TValue, TKey extends string | number = string | number> extends ɵFieldState<TValue> {}
dirty
Signal<boolean>
A signal indicating whether field value has been changed by user.
disabledReasons
Signal<readonly DisabledReason[]>
errors
Signal<ValidationError[]>
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.
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
reset
void
disabled
Signal<boolean>
A signal indicating whether the field is currently disabled.
max
Signal<number | undefined>
A signal indicating the field's maximum value, if applicable.
Applies to <input>
with a numeric or date type
attribute and custom controls.
maxLength
Signal<number | undefined>
A signal indicating the field's maximum string length, if applicable.
Applies to <input>
, <textarea>
, and custom controls.
min
Signal<number | undefined>
A signal indicating the field's minimum value, if applicable.
Applies to <input>
with a numeric or date type
attribute and custom controls.
minLength
Signal<number | undefined>
A signal indicating the field's minimum string length, if applicable.
Applies to <input>
, <textarea>
, and custom controls.
name
Signal<string>
A signal of a unique name for the field, by default based on the name of its parent field.
readonly
Signal<boolean>
A signal indicating whether the field is currently readonly.
required
Signal<boolean>
A signal indicating whether the field is required.
touched
Signal<boolean>
A signal indicating whether the field has been touched by the user.
value
WritableSignal<T>
A writable signal containing the value for this field. Updating this signal will update the data model that the field is bound to.
markAsDirty
void
Sets the dirty status of the field to true
.
void
markAsTouched
void
Sets the touched status of the field to true
.
void