Amogh Talpallikar
Amogh Talpallikar

Reputation: 12184

How to avoid reloading of controller while changing the parameter value of a route ?

Say, I have a route like: #/path/to/route/:dynamicParamter

Now whenever I click on a link where just that part is changing, angular loads the whole controller. Is there a way I can avoid this and just let my controller to all UI changes based on URL without having to reload ?

Upvotes: 1

Views: 75

Answers (1)

Chandermani
Chandermani

Reputation: 42669

If you are ready to use dynamicParamter as a querystring parameter, then you can use the $routeProvider reloadOnSearch to false. See $routeProvider documentation.

In this case your dynamicParameter changes should only change the querystring parameter and the controller would not get loaded.

To know when the querystring change look at $route#$routeUpdate event.

Upvotes: 2

Related Questions