[英]Is there a directive which allows a select element to be hidden once an option has been selected?
Is there a directive which allows a select element to be hidden once an option has been selected? 是否有一条指令允许选择一个选项后隐藏选择元素?
I thought ng-blur
was the way to go but it's not working for me. 我以为ng-blur
是要走的路,但这对我不起作用。
select(ng-model="jawn", ng-options="range.value for range in ranges",
ng-blur="hideMe", ng-if="jawnDropdown")
$scope.hideMe = function() {
$scope.jawnDropdown = false;
}
您不能以模型为中心吗?
select(ng-model="jawn", ng-options="range.value for range in ranges", ng-if="!jawn")
You can use ng-show or ng-hide by binding it with the same model of the select box in this way : 您可以通过以下方式将ng-show或ng-hide与选择框的相同模型绑定在一起来使用:
<select ng-model="modelName" ng-show="modelName == '' || modelName == null" ng-change="functionName(modelName)">
<option value="">Select name</option>
<option ng-repeat="item in items" value="item.id">{{item.name}}</select>
</select>
This will show the select box only if the modelName 's value is null or empty & when you select something the condition in ng-show returns false & the select box will hide & you can use the ng-change directive to do any other operation on the select box's value. 仅当modelName的值为null或为空时,才会显示选择框;当您选择某些内容时,ng-show中的条件将返回false,并且选择框将隐藏,并且您可以使用ng-change指令执行任何其他操作在选择框的值上。
Hope this helps Cheers 希望这对干杯有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.