# Angular Forms and Routing Apply these rules when building Angular forms, validation, routes, guards, or resolvers. ## Forms * Follow the form approach the project uses. For non-trivial forms, use typed reactive forms (`FormGroup`, `FormControl`, `NonNullableFormBuilder`; `nonNullable` controls where reset should restore the initial value) and never `Untyped*` classes in new code. * Signal forms (`@angular/forms/signals`) are stable since Angular 22. Use them for new forms only when the project is on 22+ and has adopted them; do not migrate existing forms unasked. * Keep validation rules centralized and reusable, and keep form state separate from domain state when useful. The UI/UX forms rule covers error display and input preservation. * Client-side validation is user experience; the server must validate every submission. Never treat client-side validation as a security boundary. ## Routing * Keep route definitions explicit, and lazy load larger feature areas with `loadComponent` or `loadChildren` pointing to standalone route arrays. * Write new guards and resolvers as functions (`CanActivateFn`, `ResolveFn`); keep class-based guards where the project uses them, since they remain supported. * Use `withComponentInputBinding()` to bind route parameters to component inputs where the project enables it. * Use route guards only for navigation behavior, not as a security boundary; enforce authorization on the backend. Keep resolvers focused and navigation free of expensive work. * Route and query parameters arrive as `string | null`. Parse and validate them before use and treat them as untrusted input. * With SSR, set the render mode per route in `app.routes.server.ts` (`ServerRoute` with `RenderMode.Prerender` for static pages, `RenderMode.Server` for per-request content, `RenderMode.Client` for client-only pages), registered through `provideServerRendering(withRoutes(...))`.