• Overview
@angular/forms/signals

FieldState

interface

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.

hidden

Signal<boolean>

A signal indicating whether a field is hidden.

When a field is hidden it is ignored when determining the valid, touched, and dirty states.

Note: This doesn't hide the field in the template, that must be done manually. ```

disabledReasons

Signal<readonly DisabledReason[]>

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() is true when there are no validation errors and no pending validators.
  • invalid() is true 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() is true when there are validation errors, regardless of pending validators.
  • valid() is true 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

Signal<M>

Reads an aggregate property value from the field.

@parampropAggregateProperty<M, any>

The property to read.

@returnsSignal<M>

property

M | undefined

Reads a property value from the field.

@parampropProperty<M>

The property key to read.

@returnsM | undefined

hasProperty

boolean

Checks whether the given metadata key has been defined for this field.

@paramkeyProperty<any> | AggregateProperty<any, any>
@returnsboolean

reset

void

Resets the touched and dirty state of the field and its descendants.

Note this does not change the data model, which can be reset directly if desired.

@returnsvoid

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.

pattern

Signal<readonly RegExp[]>

A signal indicating the patterns the field must match.

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.

@returnsvoid

markAsTouched

void

Sets the touched status of the field to true.

@returnsvoid
Jump to details