| technology | Angular | ||||||
|---|---|---|---|---|---|---|---|
| domain | frontend | ||||||
| level | Senior/Architect | ||||||
| version | 20 | ||||||
| tags |
|
||||||
| ai_role | Senior Angular Data Expert | ||||||
| last_updated | 2026-03-22 |
- Primary Goal: Proper implementation of data management and forms in Angular applications.
- Target Tooling: Cursor, Windsurf, Antigravity.
- Tech Stack Version: Angular 20
Note
Context: Form Safety
[(ngModel)] without strict model typing.
Risk of assigning a string to a numeric field.
Use Reactive Forms with FormControl<string> typing or new Signal-based Forms (when out of developer preview).
This approach provides a deterministic, type-safe implementation that is resilient and Agent-Readable, maintaining strict architectural boundaries.
Note
Context: Reactive Forms
const form = new FormGroup({ ... }); // Untypedform.value returns any.
const form = new FormGroup<LoginForm>({
email: new FormControl('', { nonNullable: true }),
...
});Always type forms. Use nonNullable: true to avoid string | undefined hell.
Note
Context: RxJS Patterns
this.route.params.subscribe(params => {
this.api.getUser(params.id).subscribe(user => ...);
});Classic Race Condition. If parameters change rapidly, response order is not guaranteed.
this.route.params.pipe(
switchMap(params => this.api.getUser(params.id))
).subscribe();Use Flattening Operators (switchMap, concatMap, mergeMap).
Note
Context: Network Efficiency
Ignoring request cancellation when navigating away from the page.
Requests continue hanging, consuming traffic.
HttpClient automatically supports cancellation upon unsubscription. With signals: ensure rxResource or the effect correctly cancels the request.
This approach provides a deterministic, type-safe implementation that is resilient and Agent-Readable, maintaining strict architectural boundaries.
Note
Context: Unidirectional Data Flow
this.inputData.push(newItem);The parent component remains unaware of the change. Violates the One-Way Data Flow principle.
Emit event (output) upwards; the parent changes the data and passes the new object downwards.
This approach provides a deterministic, type-safe implementation that is resilient and Agent-Readable, maintaining strict architectural boundaries.
Note
Context: Form Mixing
Using formControlName and [(ngModel)] on the same input.
Deprecated behavior. Causes form and model synchronization conflicts.
Use only one approach: either Reactive or Template-driven.
This approach provides a deterministic, type-safe implementation that is resilient and Agent-Readable, maintaining strict architectural boundaries.
Note
Context: Form Logic
Validation via HTML attributes for complex logic.
Hard to test, no reusability.
Custom Validator Functions or Async Validators in the component class.
This approach provides a deterministic, type-safe implementation that is resilient and Agent-Readable, maintaining strict architectural boundaries.
Note
Context: Performance
Validating a complex field on every keystroke (change).
Slows down user input.
new FormControl('', { updateOn: 'blur' });Trigger validation/update only when the user has finished typing.
Note
Context: UX
.subscribe(data => ...) without an error callback.
On a 500 error, the application "hangs" in a loading state.
Global Error Handler or catchError in the pipe returning a safe value.
This approach provides a deterministic, type-safe implementation that is resilient and Agent-Readable, maintaining strict architectural boundaries.
Note
Context: Maintainability
http.get('https://api.com/users')
Inability to switch environments (dev/prod).
Using InjectionToken API_URL and environment configuration.