当URL改变时,我需要设置$rootScope.VARIABLE。
我如何在$rootScope.$on回调中做到这一点呢?
$rootScope.$on('$locationChangeSuccess', function(event, absNewUrl, absOldUrl) {
$rootScope.alert =True; // $rootScope is undefined
});发布于 2016-04-14 23:32:57
在myApp.run上下文中使用您的代码。
myApp.run(["$rootScope", "$window", "$location",function ($rootScope, $window, $location) {
$rootScope.$on('$locationChangeSuccess', function(evt, absNewUrl, absOldUrl) {
$rootScope.actualLocation = $location.path();
});
$rootScope.$on('$locationChangeStart',function(evt, absNewUrl, absOldUrl) {
$rootScope.actualLocation = $location.path();
});
}]);
https://stackoverflow.com/questions/36627523
复制相似问题