在AngularJS中,我想知道是否可以使用两个可能的值过滤视图列的数据。So...if我把一个参数的值传递给一个页面的控制器,我想把数据限制在特定的值上……
Data:
Product Status
Item 1 Active
Item 2 Planned
Item 3 Completed
Item 4 Cancelled如果只需要一个值,则可以传递routeParams (如filterCol )、filterVal (如filterVal),如下所示将只显示活动项:
/programs/status/Active/
app.controller('AllItemsController', function($scope,$http,$rootScope,$routeParams){
$scope.tableFilter = {};
if($routeParams.filterCol && $routeParams.filterVal){
$scope.tableFilter[$routeParams.filterCol] = $routeParams.filterVal;
}
});我的XML看起来类似于:
<table class="table table-bordered table-condensed table-hover" ts-wrapper
<thead>
<tr>
<th ts-criteria="itmName | lowercase">Item Name</th>
<th ts-criteria="status">Status</th>
</tr>
<tr>
<th><input type="text" class="form-control input-sm" ng-model="tableFilter.itmName"></th>
<th><input type="text" class="form-control input-sm" ng-model="tableFilter.status"></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="it in allItemData | filter: tableFilter" ts-repeat ">
<td>{{it.itmName}}</td>
<td>{{it.status}}</td>
</tr>
</body>
</table>现在,如果我想发送'ActPlan‘这样的值并显示所有活动或计划的项,我如何更改控制器?(如: /programs/status/ActPlan/)
我认为我必须以某种方式改变$scope.tableFilter的设置方式(通过检查$routeParams.filterVal的值),但是我不知道如何设置表过滤器,也找不到一个例子来帮助我。我试着把它设置为“主动的,计划的”,但这并没有引起任何影响。
发布于 2015-03-27 02:49:50
如果您有几个条件,您可以只使用一个过滤器函数,比如这个thread。
https://stackoverflow.com/questions/29291997
复制相似问题