我有一个选择框,其中包含一些可过滤的选项。我想过滤两个不同的城市和类别:
HTML:
<select ng-options="c.id as c.name for c in categories" class="form-control" name="categories" ng-model="categoriesFilter">
<option value="">All</option>
</select>
<select ng-options="o.id as o.name for o in cities" class="form-control" name="cities" ng-model="citiesFilter">
<option value="">All</option>
</select>
JS:
$scope.categories = [
{name : "Private", id : 2},
{name : "Buisness", id : 1},
{name : "Deleted", id : 3}
];
我这样过滤:
<tr ng-repeat="cust in customers | filter : {city:citiesFilter||
undefined} | filter : {typeCust: categoriesFilter|| undefined} | filter :
{deleted: categoriesFilter}">
以下是完整示例:jsFiddle
答案 0 :(得分:0)
您需要链接过滤器
<tr ng-repeat="cust in customers | filter: {city: citiesFilter || undefined} | filter: { typeCust: categoriesFilter || undefined}">