← Angular learning path
Angular · Module 4 of 10

Directives and control flow

Show, hide and repeat elements with control flow blocks and directives.

📖 Key ideas

  1. New control flow: @if (cond) { } @else { }.
  2. Loop with @for (item of items; track item.id) { }.
  3. Older syntax: *ngIf and *ngFor.
  4. Attribute directives change look or behaviour: [ngClass], [ngStyle].
  5. 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