Angular · Junior · Question 55 of 75

Which variables are available inside an @for block?

@for (item of items; track item.id; let i = $index, last = $last) {
  <li>{{ i + 1 }}. {{ item.name }} @if (!last) { , }</li>
}

Explanation

They can be used directly or aliased with let. Aliases help in nested loops where the inner $index would shadow the outer one.

Further reading

Problem with a question

Angular · Junior · question 55

Test yourself

Take the Angular · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz