[英]AngularJS - hide <select> element if ng-option is empty
is it possible to hide the <select>
element if the ng-options
variables are empty after using a filter? 如果使用过滤器后ng-options
变量为空,是否可以隐藏<select>
元素?
<select class="form-control"
ng-model="selected"
ng-options="property.pstSnr.description for property in leistobToProperties | filter: {grouping:1}">
</select>
The <select>
element should not be visible if all the options of property.pstSnr.description
are empty. 如果property.pstSnr.description
所有选项均为空,则<select>
元素应该不可见。
Thanks. 谢谢。
You can define your filtered list and then use it in an ng-show
: 您可以定义过滤列表,然后在ng-show
使用它:
<select class="form-control"
ng-show="filteredSet"
ng-model="selected"
ng-options="property.pstSnr.description for property in filteredSet = (leistobToProperties | filter: filtering)">
</select>
也许
<select class="form-control" ng-model="selected" ng-show="filtered.pstSnr.description.length > 0" ng-options="property.pstSnr.description for property in filtered = (leistobToProperties | filter: {grouping:1})"></select>
I have a select as well hidden if there are no options 如果没有选项,我也会隐藏选择
<select id="categorylist" focus-on="focusMe" ng-change="UpdateDowntimeEvent()" class="col-md-11" name="CategoryId" ng-model="Model.CurrentDowntime.CategoryId" ng-options="downtimeCategory.CategoryId as downtimeCategory.CategoryName group by downtimeCategory.Node for downtimeCategory in Model.DowntimeCategories" required="" ng-hide="Model.DowntimeCategories ==0" >
You can try this 你可以试试这个
<select class="form-control" ng-model="selected" ng-options="property.pstSnr.description for property in leistobToProperties | filter: {grouping:1}" ng-hide=" property.leistobToProperties == 0"></select>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.