过滤AngularJS中的键值对?

时间:2014-10-26 14:15:39

标签: angularjs angularjs-ng-repeat angularjs-filter

我有以下选择列表,ng-model是categoryFilter

<div class="col-xs-5 col-md-2">
    <select class="form-control" ng-model="categoryFilter" style="text-transform: capitalize;"
        ng-options="category for (category, subCategories) in sportEvents">
        <option value="">Choose Category</option>
    </select>
</div>

我有以下列表区域,我想过滤列表的结果:

<div ng-repeat="(category, subCategories) in filtered = (sportEvents | filter: categoryFilter)">
    <div ng-repeat="(subCategory, subCategorySportEvents) in subCategories"
        ng-hide="filtered.length == 0">
        <h4 style="text-transform: capitalize;">{{category}} - {{subCategory}}</h4>
        <table class="table table-responsive table-striped table-hover">
            <tr ng-repeat="sportEvent in filtered = (subCategorySportEvents | filter: query | filter: dayFilter)">
                <td class="col-xs-1"><span>{{ sportEvent.number}}</span></td>
            </tr>

        </table>
    </div>
</div>

但是这里categoryFilter不起作用。是的,我可以看到其他两个过滤,但这些工作正常(查询和dayFilter都可以)。也许问题在这里,我使用键值对? (category,subCategory)? 因此,当我在选择列表中选择类别时,它不会过滤列表。

0 个答案:

没有答案