单选按钮事件第二次没有被解雇

时间:2016-05-12 12:52:47

标签: angularjs

我有两个单选按钮1.员工2客户当我必须选择员工员工ID文本框时应该打开我点击客户它应该消失。当我点击它第一次tym时,它的工作正常第二次不能正常工作。

HTML文件

   <div class="row control-group">
             <label >
                     <input name="cssPre" id="css1" value="geEmp" class="input-xlarge" type="radio" data-ng-model="addUser.Emp" ng-change="ge()">{{::'label.addUser.employee'|translate}}
            </label>

        <label >
        <input name="cssPre" id="css2" value="customer" type="radio" data-ng-model="addUser.customer" ng-change="customer()">{{::'label.addUser.Customer'|translate}}
         </label> 

我想要展示的文本框

<div ng-show="ge == true">
        <div class="row control-group"  ng-show="addUser.geEmp" ng-class="{error:addUserForm.phone.$dirty && !addUserForm.phone.$valid &&  !addUserForm.phone.$error.pattern, success:addUserForm.phone.$valid}">
               <label class="col-xs-4 col-sm-4 col-md-3 col-lg-3 control-label">{{::'label.addUser.SSO'|translate}}</label>

               <div class="col-xs-7 col-sm-7 col-md-9 col-lg-9 controls">
                  <input type="text"

                         class="input-xlarge"
                         id="sso"
                         name="phone"
                         ng-model="addUser.user.phone"
                         ng-pattern="ph_numbr"
                         placeholder="{{::'placeholder.addUser.phone'|translate}}"
                         ng-change="addUserForm.phone.$setValidity('duplicateName', true);"
                         required="true"
                         ng-maxlength=8
                         ng-minlength=8
                         ge-auto-focus
                        />

                  <span class="help-block" ng-show="addUserForm.phone.$dirty && addUserForm.phone.$error.required">{{::'error.required'|translate}}</span>
                   <span class="help-block" ng-show="addUserForm.phone.$dirty && addUserForm.phone.$error.pattern">{{::'error.number'|translate}}</span>
                  <span class="help-block" ng-show="addUserForm.phone.$dirty && addUserForm.phone.$error.maxlength">{{::'error.max.length'|translate}}</span>
                  <span class="help-block" ng-show="addUserForm.phone.$dirty && addUserForm.phone.$error.duplicateName">{{::'error.editOrganization.duplicateName'|translate}}</span>
               </div>
            </div>

JS档案

   $scope.ge = function() {

       $scope.ge = true;
   }

   $scope.customer = function() {
       $scope.ge = false;
   }

1 个答案:

答案 0 :(得分:0)

您已将变量和函数定义为ge 重命名这两者中的任何一个。

您正在根据您的代码优化$scope.ge变量

$scope.ge = function () {
    $scope.ge = true;
}

所以改为

$scope.someProperFunctionName = function () {
    $scope.ge = true;
}

HTML

<input name="cssPre" id="css1" value="geEmp" class="input-xlarge" type="radio" data-ng-model="addUser.Emp" ng-change="someProperFunctionName ()">