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>
}

Explanation

@empty replaces the common @if (todos.length === 0) check. Inside @for you can also use $index, $first, $last, $even, $odd and $count.

Further reading

Problem with a question

Angular · Junior · question 20

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