If you're still using *ngIf, *ngFor, and *ngSwitch, Angular 19 just gave you a reason to upgrade your template game.
Angular now supports JavaScript-style control flow syntax directly in your templates:
@if (user) {
<p>Hello, {{ user.name }}!</p>
} @else {
<p>Please log in.</p>
}
@for (item of items; track item.id) {
<li>{{ item.name }}</li>
} @empty {
<li>No items found.</li>
}
@switch (status) {
@case ('success') { <p>Success!</p> }
@case ('error') { <p>Error!</p> }
@default { <p>Unknown</p> }
}
β
More readable
β
Less boilerplate
β
Built-in @empty
and real @else
blocks
β
IDE-friendly and intuitive
Want to see side-by-side comparisons with the old syntax?
π Read the full breakdown
Top comments (0)