如果使用过滤器后<select>
变量为空,是否可以隐藏ng-options
元素?
<select class="form-control"
ng-model="selected"
ng-options="property.pstSnr.description for property in leistobToProperties | filter: {grouping:1}">
</select>
如果<select>
的所有选项都为空,则property.pstSnr.description
元素不应显示。
感谢。
答案 0 :(得分:2)
您可以定义已过滤的列表,然后在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>
答案 1 :(得分:0)
也许
<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>
答案 2 :(得分:0)
如果没有选项,我有一个选择隐藏
<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" >
你可以试试这个
<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>