【发布时间】:2015-05-30 04:20:00
【问题描述】:
我有一个包含多个列的大型数据表(从 json api 获取数据),并希望实现多个过滤器,执行以下操作:
- 用于选择应考虑哪个数据列的选项(包含 thead 选项的下拉菜单)[my columnFilter] 然后
- 用于过滤特定数据部分的输入字段 [my searchFilter]
我已经让 searchFilter 工作了,但我不确定如何连接 columnFilter 并使 searchFilter 仅适用于选定的数据部分。
假设我只想看到包含世界“蓝色”的描述。
如何绑定这两个过滤器并使其工作?
这是我的一些代码:
Select data column:
<select ng-model="columnFilter" ng-options="heading for heading in headings">
</select>
</div>
<div class="col-sm-12">
Filter selection: <input type='text' ng-model="searchFilter" />
</div>
<table class="table table-bordered">
<thead>
<tr>
<th>URL</th>
<th>Title</th>
<th>Traffic</th>
<th>Description</th>
<th>ID</th>
</tr>
</thead>
<tbody ng-repeat="url in urls | filter:searchFilter">
<tr>
<td>{{url.url}}</td>
<td>{{url.title}}</td>
<td>{{url.traffic}}</td>
<td>{{url.descr}}</td>
<td>{{url.id}}</td>
</tr>
</tbody>
</table>
以及一个工作插件的链接:http://plnkr.co/edit/TddllGiey0RmCx18eVdd?p=preview
【问题讨论】:
标签: javascript angularjs angularjs-ng-repeat ng-options angular-filters