I have following code in service:
function (Api) {
var user = null;
return {
checkUser: function() {
Api.checkAuth().then(function(userObj) {
user = userObj;
})
},
isLogin: function() {
this.checkUser();
return !(user == null);
}
}
}
and app.js smth like that:
app.run(AuthInfo) {
log(AuthInfo.isLogin());
if (AuthInfo.isLogin())....
}
the problem is that in console I can see only false. because checkUser() function working async and when isLogin() returns user async request wasn't finish. How can I edit my code to work with it, I need AuthInfo.isLogin() in ng-show and others services and controllers