【问题标题】:Email/ID duplicate check in AngularjsAngularjs中的电子邮件/ ID重复检查
【发布时间】:2018-04-02 05:58:56
【问题描述】:

在注册表单中,我想进行重复检查。 复制时,输入框下方会显示一条消息。

<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>

为了检查重复,我从服务器获得了计数

$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 '???' 什么意思?
  • 我的意思是,我不知道如何在 '???' 中编码。
  • 检查我的答案
  • 你有答案了吗?

标签: javascript html angularjs spring


【解决方案1】:

控制器:

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>

我使用了isDuplicate 范围变量来显示消息。

【讨论】:

    猜你喜欢
    • 2015-08-18
    • 2014-11-01
    • 2013-09-06
    • 2011-12-02
    • 1970-01-01
    • 1970-01-01
    • 2015-01-24
    • 2015-10-25
    • 2018-09-09
    相关资源
    最近更新 更多