Angular · Junior · Question 20 of 75
What does the @empty block do?
@for (todo of todos; track todo.id) {
<li>{{ todo.title }}</li>
} @empty {
<li>No tasks yet</li>
}- ✓Correct answer: Renders its content when the collection is empty
- 2Renders its content after every item
- 3Clears the list on click
Explanation
@empty replaces the common @if (todos.length === 0) check. Inside @for you can also use $index, $first, $last, $even, $odd and $count.