Control Flow
Control flow of template blocks for conditionally showing, hiding and repeating elements.
@if
@if
Conditionally displays its content when its condition expression is truthy.
Referencing the conditional expression's result
The @if
conditional supports saving the result of the conditional expression into a variable for reuse inside of the block.
@switch
@switch
This block provides an alternate syntax to conditionally render data.
@for
@for
To render content of a block for each item in a collection.
track
track
For tracking changes in the collection.
Using track
can significantly enhance your application's performance.
@empty
@empty
To define fallback content if the items
list is empty.
$index
and others
$index
and othersThere are several implicit and always available variables that Angular provides in @for
or ngFor
blocks.
$count
: Number of items in a collection iterated over.$index
: Index of the current row.$first
: Whether the current row is the firts row.$last
: Whether the current row is the last row.$even
: Whether the current index is even.$odd
: Whether the current index is odd.
Last updated