Hello,
I'm a newbie in AngularJS faced with the following problem.
I'm working a application which requires user to key in the branch detail while logging into the application.
This branch information needs to be used in subsequent controllers
So login.js which is a service has the following after successful authentication
$rootScope.currentBranch = user.branch; // Works fine, gets printed on the console
$location.path('/spend');
The spend path is wired to the template which is partial spend.html and which in turn is wired to the controller SpendCtrl
In SpendCtrl I'm using the alert to display the value of current branch
window.alert($rootScope.currentBranch);
Works perfectly well when it is re-directed to the spend.html for the first time and alerts the currentBranch the user used to login.
But when I hit F5 to refresh the browser, I'm alerted with an undefined instead of the currentBranch.
Can someone please help and explain to me what am I doing wrong here.
The angular version is 1.2.16 and the project has been generated using yeoman generator angular-fullstack.
In the same code, the $rootScope is assigned a resource object of user information details. Which I'm able to alert in the controller with the correct value evenr after hitting refresh multiple times.