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
查看更多关于【angular】angular如何让传递变量参数+ng-change的使用的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did222759