您好,我想使输入文本为空,当它成为隐藏(ng-hide="true")
我需要多个隐藏输入的动态解决方案工作
因此,如果有人选中是然后输入子计数,则如果选中否,我需要将子计数变为空
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<form ng-app>
<select ng-model="has_child">
<option value="1">Yes</option>
<option value="2">No</option>
</select>
<input type="text" ng-model="childcount" ng-hide="has_child == 2"/>
<input type="text" ng-model="mailcount" ng-hide="has_child == 2"/>
<input type="text" ng-model="femailcount" ng-hide="has_child == 2"/>
</form>
发布于 2016-10-16 04:00:41
<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>
发布于 2016-10-16 04:03:42
在select中使用ng-change
<select ng-model="has_child" ng-change="option()">并在您的控制器中添加此函数
$scope.option=function(){
if($scope.has_child==2){
$scope.childcount='';
}
console.log($scope.childcount);
}谢谢
https://stackoverflow.com/questions/40063599
复制相似问题