【angular】angular如何让传递变量参数+ng-change的使用


HTML:
 1 <div class="form-group">
 2     <label class="col-sm-2 control-label">商户名称</label>
 3     <div class="col-sm-4">
 4          <input type="text" class="form-control " id="merchantName" ng-model="merchant.name"
 5                 ng-init="123" value="{{name}}" placeholder="请输入商户名称" 
 6                 ng-class="{'red-border':merchantNameState}" 
 7                 ng-change="tipState(this,'merchantNameState')">
 8      </div>
 9      <div class="col-md-4 red-font" ng-show="merchantNameState">请输入商户名称</div>
10 </div>

 

JS:
1 $scope.tipState=function (x,stateName) {
2       if(x.value!==''){
3            $scope[stateName]=false;
4       }
5  };

 

 

  • 传递变量参数;

         $scope[stateName]=false

  • ng-change的使用
        必须定义 ng-model
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM