Sanjeev
Sanjeev

Reputation: 855

How to prevent a component to load again on query parameter change in angular2?

this.router.navigate(['CurrentComponent', {id: this._id, param1: value}]);

Above code updates the query parameters of the present url. And after the url is changed, the component loads again. How to prevent the reload of component and only update the query parameters ?

Upvotes: 2

Views: 641

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657078

Add a method routerCanReuse to your component and return true

routerCanReuse(next: ComponentInstruction, prev: ComponentInstruction) { return true; }

See also CanReuse

Upvotes: 1

Related Questions