I have two factory
functions:
Factories
factory.getCurrEmployee = function()
{
data = {"api_token": authenticationFactory.getToken()};
url = GLOBALS.url + 'show/employee/' + $cookieStore.get('employeeid');
return requestFactory.post(url, data)
.then(function (response) {
return response.data.result.Employee;
}, function () {
$window.location.assign('/');
});
}
factory.isSuperadministrator = function() {
factory.getCurrEmployee().then(function (employee) {
if(employee.Role == 'Superadministrator')
{
return true; //console.log('Superadministrator') <- that console.log is visible in my console
}
return false;
});
}
return factory;
In the controller, I expect to receive either true or false (indicating whether a user is a Superadministrator or not), but the result is blank. When I console.log in my factory.isSuperadministrator, the result is true.
Controller
console.log(employeeFactory.isSuperadministrator());
Why is this not functioning as expected?