What you will learn
Render conditional and repeated UI with Angular's modern template blocks.
- Angular's built-in control flow uses @if, @else, @for, @empty, and @switch. New Angular 22 code does not need CommonModule merely to use these blocks.
- The track expression identifies each record across insertions, deletion, and reordering. Prefer a stable database ID rather than $index for a mutable list.
- Filter or sort data in TypeScript using computed state when the transformation is substantial. Keep the template focused on display.
- Use @empty to explain an empty result instead of leaving an unexplained blank area.
How it works
1Signals hold records
2computed filters records
3@for tracks identity
4@if chooses each view
Expected result
Asha and Meena appear. Asha is labelled Excellent, while Meena is labelled Passed.
Common mistakes
Do not track mutable records by index. Do not mutate an array in place and expect every dependent computation to understand the change. Avoid deeply nested control blocks when a child component would be clearer.
