i'm building a login service to my website and i need help on this: i want to check if login was done and if is true do the function at 'yes' variable. Else, do the 'no' variable. Like this:
app.service('login', function($cookies) {
// Cookie status = login status
var cookie_status = $cookies.get('login_status');
// Cookie token = login token
var cookie_token = $cookies.get('login_token');
this.status = function(){
return cookie_status
};
this.iflogin = function(yes, no){
if(cookie_status=='yes'){
return yes;
} else {
no;
}
}; });
But, therefore, when i call this function the function at 'yes' or 'no' variable aren't done. That is my call:
login.iflogin(function yes(){
$scope.login = "Conta";
}, function no(){
$scope.login = "Login";
});
Where is the problem!?
Thank you and sincerely, Lucas.