Question

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 ?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top