AngularJS - 隐藏<选择>元素,如果ng-option为空
AngularJS - hide <select> element if ng-option is empty
如果使用过滤器后ng-options
变量为空,是否可以隐藏<select>
元素?
<select class="form-control"
ng-model="selected"
ng-options="property.pstSnr.description for property in leistobToProperties | filter: {grouping:1}">
</select>
如果 property.pstSnr.description
的所有选项都为空,则 <select>
元素不应可见。
谢谢。
您可以定义过滤列表,然后在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>
JS小提琴
也许
<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>
如果没有选项,我也隐藏了一个选择
<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>
相关文章:
- 如果文本字段为空,则使用JavaScript应用CSS样式
- 如果localstorage为空,则显示欢迎消息
- 如果值为空,如何设置输入的默认值?jQuery
- 如何检查元素的内容是否为空,如果为空,请在jquery中删除该元素
- 如果数据为空,Ajax加载不会停止
- 边框颜色是't如果输入为空,则更改
- 如果用户没有更改,则表单值为空
- jQuery/Javascript foreach If/Else |如果为空(不执行任何操作)Else(显示forea
- Javascript:如果数组有对象或不为空
- 如果设置了过期日期,则Javascript Cookie为空
- Don'如果字段为空,则不运行函数
- 如果所有模型值都不为空,则显示角度
- 如果文本框为空,则不起作用
- Jquery,onBlur-如果不为空,则显示警报
- 表单提交没有'如果为空,则不会显示错误消息
- 如果值为空或0,如何更改html select标记的边框颜色
- 如果上一个
为空,则向上移动表数据 d - 在提交时检查正则表达式验证,如果为空,则聚焦所有输入字段
- 如果上一个元素为空,则隐藏下一个元素
- 如果文本字段不为空,则自动将表单提交到url