0

I am trying to get the value of $rootScope.exists from the SomeService.getData() function. When I see the rootScope (using console.log) outside the function, I can see the $rootScope.exists value but on printing it, it says its undefined.

How can I get the value?

else {
    SomeService.getData().then(function (response) {
        $rootScope.1a = response.data;
        $rootScope.levels = response.data.levels;
        $rootScope.exists = checkAvailability($rootScope.accessLevels, "DataDAta");
    });
    console.log("sadsad", $rootScope.exists);
    if ($rootScope.exists) {
        $location.path('/ABC');
    }
    else {
        $location.path('/DEF');
    }
}
Maddy
  • 2,025
  • 5
  • 26
  • 59

1 Answers1

1

Did you inject '$rootScope' into your modules array?

app.controller('LoginCtrl', function($rootScope) {

}
Shashank Vivek
  • 16,888
  • 8
  • 62
  • 104