i have services , controllers written in angularjs, in sending post request node.js application , using send status , code send error message username exists
orwrong email , password
not getting how show these errors in frontend html. after submit pressed probably. how go it?
$http.post('/register', registeruser).then(function(response){ console.log(response.data); }
how show response .data in html. read $error in angular don't think work in case mine custom error.
thanks
your html should like:
<div ng-if="errormessage">{{ errormessage }}</div>
then can modify $scope.errormessage
display it:
$http.post('/register', registeruser).then(function(response){ switch(response.data) { case 'loginexists': $scope.errormessage = 'username exists'; break; case 'loginerror': $scope.errormessage = 'wrong email , password'; break; default: $scope.errormessage = false; } }
Comments
Post a Comment