• Overview
@angular/forms/signals

FieldState

interface

Contains all of the state (e.g. value, statuses, etc.) associated with a Field, exposed as signals.

API

    
      interface FieldState<TValue, TKey extends string | number = string | number> {
}

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.

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. ```

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() 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.

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

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

markAsTouched

void

Sets the touched status of the field to true.

@returnsvoid

markAsDirty

void

Sets the dirty status of the field to true.

@returnsvoid

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
Jump to details