3
votes

According to the Angular 2 docs:

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 need help figuring out why this does not work on my lazy-loaded routes. To reproduce:

  • Open this plunker
  • On LazyLoadedComponent press Next ID button to trigger navigation to the same route (new param). Notice that the component is destroyed and a new instance is initialized each time.

enter image description here

  • On HomeComponent, things work as expected. Triggering navigation executes the ActivatedRoute.params.subscribe() callback but the component is not re-initialized

enter image description here

I'm using Angular 2 rc.5 and Angular Router 3 rc.1 Why does my lazy-loaded component not behave in accordance with the docs?

1

1 Answers

1
votes

This is an Angular bug. It has been reported and the next version should be fixed. See https://github.com/angular/angular/pull/10707