
Angular Control Flow
- 168 installs
- 6 repo stars
- Updated April 4, 2026
- oguzhan18/angular-ecosystem-skills
Migrate templates to Angular control flow (@if, @for, @switch) for clearer conditional rendering and typed loop variables.
About
Explains Angular built-in control flow from oguzhan18/angular-ecosystem-skills covering @if, @for, @switch, track expressions, and migration from structural directives so Claude writes clearer, type-safe Angular templates.
- @if and @else blocks
- @for with track expressions
- @switch template syntax
- Migration from *ngIf/*ngFor
- Typed template variables
Angular Control Flow by the numbers
- 168 all-time installs (skills.sh)
- +1 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #927 of 2,245 Frontend Development skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/oguzhan18/angular-ecosystem-skills --skill angular-control-flowAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 168 |
|---|---|
| repo stars | ★ 6 |
| Last updated | April 4, 2026 |
| Repository | oguzhan18/angular-ecosystem-skills ↗ |
What it does
Migrate templates to Angular control flow (@if, @for, @switch) for clearer conditional rendering and typed loop variables.
Files
Angular Control Flow
Version: Angular 17+ (2025) Tags: Control Flow, @if, @for, @switch, @defer
References: Control Flow • Deferrable Views
API Changes
This section documents recent version-specific API changes.
- NEW: @if replaces *ngIf — New control flow syntax
- NEW: @for replaces *ngFor — New loop syntax with track
- NEW: @switch replaces ngSwitch — New switch syntax
- NEW: @defer — Lazy load components
- DEPRECATED: ngIf, ngFor, *ngSwitch — Migrate to new syntax
Best Practices
- Use @if for conditionals
@Component({
template: `
@if (isLoggedIn) {
<p>Welcome!</p>
} @else {
<p>Please login</p>
}
`
})
export class MyComponent {
isLoggedIn = signal(false);
}- Use @else if
@Component({
template: `
@if (user.role === 'admin') {
<p>Admin panel</p>
} @else if (user.role === 'user') {
<p>User dashboard</p>
} @else {
<p>Guest view</p>
}
`
})
export class MyComponent {}- Use @for for loops
@Component({
template: `
@for (item of items; track item.id) {
<li>{{ item.name }}</li>
}
`
})
export class MyComponent {
items = [{ id: 1, name: 'A' }, { id: 2, name: 'B' }];
}- Use track for performance
@for (user of users; track user.id) {
<li>{{ user.name }}</li>
}- Use @empty for empty lists
@Component({
template: `
@for (item of items; track item.id) {
{{ item.name }}
} @empty {
<p>No items found</p>
}
`
})
export class MyComponent {}- Use @switch for conditionals
@Component({
template: `
@switch (status) {
@case ('loading') {
<p>Loading...</p>
}
@case ('success') {
<p>Success!</p>
}
@case ('error') {
<p>Error occurred</p>
}
@default {
<p>Unknown status</p>
}
}
`
})
export class MyComponent {
status = 'loading';
}- Use @defer for lazy loading
@Component({
template: `
@defer (on viewport) {
<heavy-chart />
} @placeholder {
<div>Loading chart...</div>
}
`
})
export class DashboardComponent {}- Use @defer with conditions
@Component({
template: `
@defer (on hover) {
<tooltip />
}
@defer (when isReady) {
<ready-component />
}
`
})
export class MyComponent {}- Migrate from *ngIf
ng generate @angular/core:control-flow- Use else with @if
@if (condition) {
content
} @else {
alternative
}