Not sure if this is a bug or not. When using a RouteProvider, the code within a controller constructor runs every time the route changes. So, in the following example, I call fetchData() to load the initial data that is loaded in a view.
@NgController(
selector: '[my-controller]',
publishAs: 'ctrl'
)
class MyController implements NgDetachAware {
...
MyController(RouteProvider router) {
linkId = router.parameters['linkId'];
route = router.route.newHandle();
fetchData();
}
}
But anytime I navigate to a route, the code in the constructor executes, and the data gets fetched.
Is this a bug? If not, what is the correct way to set values when the view loads?