In angular's run block i am setting one property on $rootScope however when controller executes that property doesn't exists on $rootScope.
When application starts, in debugger i see "adal:loginSuccess" handler gets executed and $rootScope.isAdmin do get sets to "true", however when controller start executing the $rootScope.isAdmin doesnt exists on $rootScope. Why? Below is my code
app.js
var main = angular.module('mymodule', [
'ngAnimate','ngRoute','Mycontrollers','AdalAngular'...
]);
main.config(['$httpProvider','adalAuthenticationServiceProvider', function ($httpProvider,adalProvider) {
adalProvider.init(
{
// config Azure Client ID Here
},
$httpProvider
);
}]);
main.run(["$rootScope", "$state", "API", "usSpinnerService",
function ($rootScope, $state, API, usSpinnerService,) {
$rootScope.$on("adal:loginSuccess", function () {
$rootScope.isAdmin = user.isAdmin;
});
}]);
Controller.js
angular.module('Mycontrollers', [])
.controller('HeaderCtrl', ['$rootScope','$scope', 'adalAuthenticationService', function ($rootScope, $scope, adalAuthenticationService) {
//$rootScope.isAdmin is set in angular's run block above
//however $rootScope.isAdmin does not exists here, WHY?????
}])