i have a value inside $rootscope and i want to access this value inside the config function , this is my code :
--run function
myApp.run(function ($rootScope) {
$rootScope.myVariable = "my value";
});
--config function
myApp.config(['$provide','$routeProvider','$stateProvider','$urlRouterProvider',function($provide,$routeProvider,$stateProvider,$urlRouterProvider) {
// here ,i want to access to myVariable value to do some tests
$urlRouterProvider.otherwise(function($injector){
var $state = $injector.get('$state');
var $rootScope = $injector.get('$rootScope');
alert($rootScope.myVariable == "1");
if ($rootScope.myVariable) {
$state.go('mystat1');
}
else {
$state.go('mystat2');
}
});
}]);
any idea how to achieve this.
thanks in advance