Angular · Junior · Question 35 of 75

When is ngOnDestroy called?

Explanation

Use it (or DestroyRef.onDestroy) to stop timers, unsubscribe from long-lived Observables and detach listeners. Otherwise they keep running and leak memory.

Further reading

Problem with a question

Angular · Junior · question 35

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