使用select清除angularJS中的过滤器
发布时间:2020-12-17 07:22:41 所属栏目:安全 来源:网络整理
导读:我在下面给出的 HTML中使用ngOptions指令: select ng-model="selectedGroupToShow.Id" ng-options="g.Id as g.Name for g in myGroups" option value-- All --/option/select 我在ng-repeat中使用的过滤器显示我的数据是这样的: filter:{GroupId:selectedG
我在下面给出的
HTML中使用ngOptions指令:
<select ng-model="selectedGroupToShow.Id" ng-options="g.Id as g.Name for g in myGroups"> <option value>-- All --</option> </select> 我在ng-repeat中使用的过滤器显示我的数据是这样的: filter:{GroupId:selectedGroupToShow.Id}" 即使我使用 filter:selectedGroupToShow 问题保持不变.重置过滤器.. 这非常有效,但是当我想清除过滤器时(选择默认选项 – “全部”),它只会显示根本没有设置GroupId参数的数据. 在select中选择默认选项元素时,如何显示所有数据(清除过滤器)?
我想我理解你的问题,你所面临的问题是当选择下拉菜单时–ALL–它的值为null且未定义.
因此要重置它,您必须将其设置为undefined. <div ng-repeat="item in items| filter:{itemId:selectedGroupToShow.Id||undefined}"> {{item.itemId}} </div> 请参考我为您的问题创建的以下小提琴. fiddle (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |