Angular · Senior · Question 15 of 75

Why are getters or methods in templates a common performance problem?

@for (p of filteredProducts(); track p.id) { <li>{{ p.name }}</li> }
filteredProducts() { return this.products.filter((p) => p.visible); }

Explanation

Turn derived data into a computed() signal or a pure pipe: it is recalculated only when the inputs change. Profile with Angular DevTools to find components that check too often.

Further reading

Problem with a question

Angular · Senior · question 15

Test yourself

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

Take this quiz