Angular

Last Updated: 11/20/2026

Signal Forms

Angular Signal Forms (introduced in Angular 21 and stabilized in Angular 22 under @angular/forms/signals) provide a model-first, type-safe alternative to Reactive Forms. Instead of wrapping data inside separate FormGroup and FormControl classes, your plain TypeScript data stored inside a writable signal() serves as the single source of truth

Core Architecture & Concepts

  • Data Model Signal (signal<T>()). You start with a standard writable signal holding a typed interface. Updating this signal automatically updates the UI, and typing in the UI updates the signal.
  • form() & the FieldTree. Passing your model signal to form(model, schemaFn) generates a strongly typed FieldTree that mirrors the exact shape of your data. Accessing myForm.email() returns a FieldState object containing reactive signals like .value(), .valid(), .invalid(), .touched(), .dirty(), and .errors().
  • Declarative Schema Validation. Instead of attaching validator arrays to individual controls, you pass a schema callback to form(). Functions like required(), email(), minLength(), debounce(), and disabled() apply rules using type-safe field paths.
  • [formField] Directive. A single directive binds both native HTML inputs and custom components directly to a FieldTree node (e.g., [formField]="loginForm.email").
  • Custom Controls Without ControlValueAccessor. Custom form components simply implement FormValueControl<T> with a value = model<T>() signal, eliminating NG_VALUE_ACCESSOR providers and callback boilerplate.

Signal Forms vs. Reactive Forms

Feature Reactive Forms (Legacy) Signal Forms (Angular 22+)
Source of Truth Duplicated between FormGroup internal state and your domain data model. Your writable signal<T>() model directly.
Type Safety form.get('nested.field') uses string paths and defaults controls to T | null. Full compile-time dot notation (form.nested.field) with exact model types.
Dynamic Rules Imperative .disable(), .setValidators(), and valueChanges subscriptions. Reactive schema rules (applyWhen(), disabled(), hidden()) that re-evaluate automatically.
Custom Controls ControlValueAccessor + NG_VALUE_ACCESSOR + forwardRef boilerplate. Single value = model() property via FormValueControl<T>.

1. Main Registration Form Component

import { Component, signal } from '@angular/core';
import { email, form, FormField, minLength, required } from '@angular/forms/signals';

interface LoginData {
  email: string;
  password: string;
}

@Component({
  selector: 'app-login-form',
  imports: [FormField, BasicInput, RatingPickerComponent],
  template: `
    <form (submit)="onSubmit($event)">
      @if (loginForm.email().touched() && loginForm.email().invalid()) {
        @for (error of loginForm.email().errors(); track error) {
          <p>{{ error.message }}</p>
        }
      }
      @if (loginForm.password().touched() && loginForm.password().invalid()) {
        @for (error of loginForm.password().errors(); track error) {
          <p>{{ error.message }}</p>
        }
      }
      <label>
        Email:
        <input type="email" [formField]="loginForm.email" />
      </label>

      <label>
        Password:
        <input type="password" [formField]="loginForm.password" />
      </label>

      <p>Hello {{ loginForm.email().value() }}</p>
      <p>Password {{ loginForm.password().value().length }}</p>

      <input type="submit" value="Submit" />
    </form>
  `,
})
export class LoginFormComponent {
  loginModel = signal<LoginData>({
    email: '',
    password: ''
  });

  loginForm = form(this.loginModel, (schemaPath) => {
    required(schemaPath.email, { message: 'Email is required' });
    email(schemaPath.email, { message: 'Enter a valid email address' });
    required(schemaPath.password, { message: 'Password is required' });
    minLength(schemaPath.password, 8, { message: 'Password must be minimum 8 chars' });
  });

  onSubmit(event: Event) {
    event.preventDefault();

    const credentials = this.loginModel();
    console.log('Logging in with:', credentials);
  }
}

2. Custom Form Control (FormValueControl)

Custom components can implement FormValueControl<T> rather than traditional ControlValueAccessor boilerplate, exposing a value = model<T>() signal directly bound via [formField]:

import { Component, model, output } from '@angular/core';
import { FormValueControl } from '@angular/forms/signals';

@Component({
  selector: 'app-rating-picker',
  template: `
    <div class="stars">
      @for (star of [1, 2, 3, 4, 5]; track star) {
        <button
          type="button"
          [class.selected]="star <= value()"
          (click)="selectRating(star)"
        >
          ★
        </button>
      }
    </div>
  `,
})
export class RatingPickerComponent implements FormValueControl<number> {
  value = model<number>(0);
  touch = output<void>();

  selectRating(rating: number) {
    this.value.set(rating);
    this.touch.emit();
  }
}
<label>
  Rating
  <app-rating-picker [formField]="feedbackForm.rating"></app-rating-picker>
</label>

References