• Overview
@angular/forms/signals

form

function

API

function form<TValue>(model: WritableSignal<TValue>): Field<TValue>;
function form<TValue>(
  model: WritableSignal<TValue>,
  schemaOrOptions: FormOptions | SchemaOrSchemaFn<TValue>,
): Field<TValue>;
function form<TValue>(
  model: WritableSignal<TValue>,
  schema: SchemaOrSchemaFn<TValue>,
  options: FormOptions,
): Field<TValue>;
function form<TValue>(model: WritableSignal<TValue>): Field<TValue>;

Creates a form wrapped around the given model data. A form is represented as simply a Field of the model data.

form uses the given model as the source of truth and does not maintain its own copy of the data. This means that updating the value on a FieldState updates the originally passed in model as well.

@parammodelWritableSignal<TValue>

A writable signal that contains the model data for the form. The resulting field structure will match the shape of the model and any changes to the form data will be written to the model.

@returnsField<TValue>
function form<TValue>(model: WritableSignal<TValue>, schemaOrOptions: FormOptions | SchemaOrSchemaFn<TValue>): Field<TValue>;

Creates a form wrapped around the given model data. A form is represented as simply a Field of the model data.

form uses the given model as the source of truth and does not maintain its own copy of the data. This means that updating the value on a FieldState updates the originally passed in model as well.

@parammodelWritableSignal<TValue>

A writable signal that contains the model data for the form. The resulting field structure will match the shape of the model and any changes to the form data will be written to the model.

@paramschemaOrOptionsFormOptions | SchemaOrSchemaFn<TValue>

The second argument can be either

  1. A schema or a function used to specify logic for the form (e.g. validation, disabled fields, etc.). When passing a schema, the form options can be passed as a third argument if needed.
  2. The form options
@returnsField<TValue>
function form<TValue>(model: WritableSignal<TValue>, schema: SchemaOrSchemaFn<TValue>, options: FormOptions): Field<TValue>;

Creates a form wrapped around the given model data. A form is represented as simply a Field of the model data.

form uses the given model as the source of truth and does not maintain its own copy of the data. This means that updating the value on a FieldState updates the originally passed in model as well.

@parammodelWritableSignal<TValue>

A writable signal that contains the model data for the form. The resulting field structure will match the shape of the model and any changes to the form data will be written to the model.

@paramschemaSchemaOrSchemaFn<TValue>

A schema or a function used to specify logic for the form (e.g. validation, disabled fields, etc.)

@paramoptionsFormOptions

The form options

@returnsField<TValue>
Jump to details