I am defining a global $rootScope variable like this:
var app = angular.module("demoApp", []);
app.run(function ($rootScope) {
$rootScope.test = "Global";
});
and in my html if I access this as {{test}} it works.
But in my controller if I change the value of this variable inside my controller and change the location using $location.path(....); then this global variable value remain same.
function myCtrl($location, $rootScope) {
$rootScope.test = "Changed to Local";
$location.path("New.html");
}
Now in my New.html if I access this variable {{test}} it prints as 'Global' instead of 'Changed to Local'. But if I refresh the page, then it works fine.
Please help how to avoid this refresh issue. Can I use resolve/promise inside the ' app.run.....'? If so how to do it.