← Angular learning pathAngular · Module 4 of 10
Directives and control flow
Show, hide and repeat elements with control flow blocks and directives.
📖 Key ideas
- New control flow: @if (cond) { } @else { }.
- Loop with @for (item of items; track item.id) { }.
- Older syntax: *ngIf and *ngFor.
- Attribute directives change look or behaviour: [ngClass], [ngStyle].
- Create custom directives with @Directive.
💡 Real-life example: Directives are stage directions in a script: "enter here", "repeat this line", "speak louder".
@ifConditional block
@forLoop block with track
*ngForOlder loop directive
Attribute directiveChanges element look or behaviour