Hello,
I'm newbie in AngularJS, i would like create service authentification.
The function isConnected call API rest and should be return true is
authentification is ok and false is ko.
How test code status http to return true or false ?
app.service("authService", ['$rootScope', '$http', '$resource',
function($rootScope, $http, $resource) {
return {
isConnected : function() {
var auth = $resource('/api/auth').get();
// how test code status 200 or 401
if (auth.codeStatus === 200){
return true;
} else {
return false;
}
},
logIn : function($login, $password) {
// ...
$rootScope.$broadcast("connectionStateChanged");
},
logOut : function() {
// ...
$rootScope.$broadcast("connectionStateChanged");
}
};
});
Thank
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.