Angularjs : make input = null when ng-hide = true
Angularjs : make input = null when ng-hide = true
你好,我想让输入文本为空当它变成隐藏(ng-hide="true")
我需要多个隐藏输入的动态解决方案
因此,如果有人选择了Yes,则输入子数如果选中了No,则需要child count变为空
<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>
<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>
在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);
}
谢谢
相关文章:
- 使用angularjs ng Show/ng hide显示和隐藏不同的内容
- 我需要NG-IF/NG-SWITCH还是NG-SHOW&NG-HIDE
- 使用ng-hide根据条件显示/隐藏按钮
- ng show和ng hide don'I don’我一秒钟都不工作
- 使用 ng-hide 切换表中的列,其中 colRessize 可调整大小
- 实时 Angular js ng-hide 不起作用
- AngularJS:隐藏<td>使用ng-hide/ng-show没有间隙
- 使ng-show/ng-hide与由Angular之外的外部源修改的localStorage一起工作
- 是否可以使用相同的变量使ng if的行为类似于ng show/ng hide
- angular ng show/ng hide无法正确使用ng bind html
- ng-hide 元素出现一段时间,然后隐藏
- ng-show / ng-hide / ng-if 不适用于 Angular 指令
- 切换 标记在使用 ng-hide/show 和布尔值时失败
- AngularJS ng-hide in nested dictionary
- 不要在窗体序列化时将元素包含在 ng-hide 中
- ng-hide and ng-show without Javascript
- angularjs $index when ng-hide with ng-repeat
- AngularJS在使用ng-show ng-hide时,我仍然看到这两个对象1ms
- Angular js ng-show and ng-hide with animation using toggle c
- Angularjs : make input = null when ng-hide = true