• Overview
@angular/forms/signals

Submits a given FieldTree using the given action function and applies any submission errors resulting from the action to the field. Submission errors returned by the action will be integrated into the field as a ValidationError on the sub-field indicated by the fieldTree property of the submission error.

API

function submit<TModel>(  form: FieldTree<TModel>,  action: (form: FieldTree<TModel>) => Promise<TreeValidationResult>,): Promise<void>;

Usage Notes

async function registerNewUser(registrationForm: FieldTree<{username: string, password: string}>) {  const result = await myClient.registerNewUser(registrationForm().value());  if (result.errorCode === myClient.ErrorCode.USERNAME_TAKEN) {    return [{      fieldTree: registrationForm.username,      kind: 'server',      message: 'Username already taken'    }];  }  return undefined;}const registrationForm = form(signal({username: 'god', password: ''}));submit(registrationForm, async (f) => {  return registerNewUser(registrationForm);});registrationForm.username().errors(); // [{kind: 'server', message: 'Username already taken'}]
Jump to details