我在过滤器下拉列表中添加了默认选项“全部”以显示所有结果,但是当我使用某个组名称进行过滤,然后尝试使用“全部”过滤时,不会显示任何结果。如何在选择所有选项时显示所有结果?
<input type="text" ng-model="search" class="input-control width-100" />
<select ng-model="group" ng-options="gp.groupID as gp.groupName for gp in groups" class="input-control width-100"><option value="" selected>All</option></select>
<table id="tbl-holidaylist" class="table table-striped table-bordered">
<thead>
<th width="40%">Type</th>
<th width="40%">Group</th>
</thead>
<tbody>
<tr ng-repeat="tp in types |filter:{'groupID':group}|filter:search">
<td>{{ tp.ExpenseTypeName }}</td>
<td>{{ tp.ExpenseGroupName }}</td
</tr>
</tbody>
</table>
答案 0 :(得分:0)
我认为你指的是像这样的功能
<select ng-model="selected" ng-options="a as a for a in arr">
<option value="">All</option>
</select>
<ul>
<li ng-repeat="a in arr | filter:selected">{{a}}</li>
</ul>
答案 1 :(得分:0)
我创建了您的应用,这里是Link
public class Helper {
public class var isIpad:Bool {
if #available(iOS 8.0, *) {
return UIScreen.mainScreen().traitCollection.userInterfaceIdiom == .Pad
} else {
return UIDevice.currentDevice().userInterfaceIdiom == .Pad
}
}
public class var isIphone:Bool {
if #available(iOS 8.0, *) {
return UIScreen.mainScreen().traitCollection.userInterfaceIdiom == .Phone
} else {
return UIDevice.currentDevice().userInterfaceIdiom == .Phone
}
}
}
问题是当选择全部时,组变为未定义,导致过滤器无效