0
votes

In Routing & Navigation tutorial for angular 2, section OBSERVABLE PARAMS AND COMPONENT RE-USE, the tutorial said "By default, the router reuses a component instance when it re-navigates to the same component type without visiting a different component first. The parameters can change between each re-use."

I created static counters and put console.log inside ngOnInit of hero-list, hero-detail component, Crisis-list, Crisis-detail component. I can see those counters got increased every time I navigate back and for "without visiting a different component first". Any idea?

1

1 Answers

0
votes

"By default, the router reuses a component instance when it re-navigates to the same component type without visiting a different component first."

It would resuse the same component instance when you set up a router guard, which is an intermediary service that has the ability to prevent the router from navigating somewhere, effectively navigating back to the same component.