In Sign up form, I wanna make Duplication check. When is duplicated, A message is shown below the input box.
<div class="form-group">
<label class="col-md-2 control-label"><strong>Email</strong></label>
<div class="col-md-10">
<input type="email" class="form-control" name="usr_Email"
ng-model="usrEmail" ng-keyup="checkDuplicate()">
<span class="help-block"
ng-show="signupForm.$submitted || signupForm.usr_Email.$touched">
<div ng-show="?????" class="text-danger">is duplicated!</div>
</span>
</div>
</div>
to check duplicate, I got counting number from server
$scope.user.usrEmail = $scope.usrEmail;
var req = {
method: 'POST',
url: './api/v1/public/checkDuplication',
dataType: 'json',
headers: {
'Content-Type': 'application/json; charset=utf-8'
},
data: angular.toJson($scope.user)
};
$http(req).success(function(data, status, headers, config){
$log.debug($filter('json')(data));
if(data.number == 0){
???????
}
else{
???????????????
}
I'm very confused about what I should write in '???'
In advance, thanks!
Controller:
if(data.number == 0){
//If email id is duplicate, then show the message in UI
$scope.isDuplicate = true;
} else{
//If email id is not duplicate, then hide the message in UI
$scope.isDuplicate = false;
}
HTML:
<div ng-show="isDuplicate" class="text-danger">is duplicated!</div>
I have used isDuplicate scope variable to show the message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With