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');
}
}