Angularjs:当ng-hide = true时,使输入= null

时间:2016-10-15 19:56:24

标签: javascript jquery angularjs

您好我想让输入文本为空 当它变得隐藏时(ng-hide =" true")

我需要针对多个隐藏输入的动态解决方案

所以,如果有人检查是,则输入子计数 然后,如果选中不,我需要孩子计数变空



.eqv




2 个答案:

答案 0 :(得分:0)



<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<form ng-app>
<select ng-model="has_child" ng-change='has_child == 2 ? childcount=null: ""'>
<option value="1">Yes</option> 
<option value="2">No</option>
</select>

<input type="text" ng-model="childcount" ng-hide="has_child == 2"/>
</form>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

在选择中使用ng-change

<select ng-model="has_child" ng-change="option()">

并在控制器中添加此功能

$scope.option=function(){
    if($scope.has_child==2){
    $scope.childcount='';
    }
    console.log($scope.childcount);
}

由于