Click to watch Angular Playlist: • Angular 18
To view the code of this tutorial. Please visit this Github link: https://github.com/lets-build-with-co...
Note : Switch the particular branch of the tutorials of Github
Angular 18 - Control Statements @for Contextual Variables
Inside @for contents, several implicit variables are always available:
Variable Meaning
$count Number of items in a collection iterated over
$index Index of the current row
$first Whether the current row is the first row
$last Whether the current row is the last row
$even Whether the current row index is even
$odd Whether the current row index is odd
These variables are always available with these names, but can be aliased via a let segment:
The aliasing is especially useful in case of using nested @for blocks where contextual variable names could collide.