I am using angular router` to track the state of my web app like this:
when('/', { controller: "AController", templateUrl: "APanel.html" }). when('/subpage/:id', { controller: "BController", templateUrl: "BPanel.html" }). And I am using Angular Service to track some shared values:
app.service('stateService', function() { this.someSwitch = false; this.someLongDataArray = [x, y, z]; }); Currently, before changing path to \subpage\:id url from AController, I will assign new values to members of the service, so they can be referenced in subpages.
Now the question is, if user directly launching the subpage url \subpage\:id, or hit the refresh button on browser on subpage, BController will be invoked, and I will lost the values in the service which are supposed to be prepared by AController.
I am wondering what I should do in this case. is there any way I can get called when user launch the subpage directly, so I have a chance to prepare the data? (Maybe I can watch for html onload event, but not sure that's the best answer).
Thanks