Reputation: 4649
I have a ProfileComponent, inside the page user can click on letters to filter profile start with it.
Entry Point: /profile
A B C ... X Y Z
When user click on these letters -> url: /profile
-> /profile/;startWith=X
.
I want to keep the startWith
parameters in URL, however I notice Angular 2 will destroy current component then recreate and initialize the same component again. How to keep URL params without reinitializing component?
Upvotes: 2
Views: 174
Reputation: 657416
If you implement CanReuse
routerCanReuse(next: ComponentInstruction, prev: ComponentInstruction) { return true; }
in your component, the router should keep the same instance instead of re-creating a new one.
Upvotes: 1