Angular · Middle · Question 34 of 75

Why does a component not re-run ngOnInit when navigating from /users/1 to /users/2?

Explanation

Read the param reactively: an input with withComponentInputBinding, or route.paramMap combined with switchMap. Reading the snapshot once in ngOnInit shows stale data.

Further reading

Problem with a question

Angular · Middle · question 34

Test yourself

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

Take this quiz