我正在使用ngTable指令为我的表添加很棒的过滤。我的观点是:
<table ng-table="tableParams" show-filter="true" class="table table-bordered table-hover table-condensed table-striped">
<tr ng-repeat="item in items">
<td class="text-center">
<input type="checkbox" />
</td>
<td data-title="'SKU'" filter="{ 'sku': 'text' }" sortable="'sku'">
<a href="/company/item/{{ item._id }}">{{ item.sku }}</a>
</td>
<td data-title="'Description'" filter="{ 'description': 'text' }">
<a href="/company/item/{{ item._id }}">{{ item.description }}</a>
</td>
<td data-title="'Client'" filter="{ 'client.name': 'select' }">
{{ item.client.name }}
</td>
<td data-title="'Active'" filter="{ 'active': 'select' }" class="text-center">
{{ item.active }}
</td>
<td>
DEACTIVE / EDIT
</td>
</tr>
</table>
我的控制器有:
$scope.tableParams = new ngTableParams({
page: 1, // show first page
count: 10, // count per page
}, {
total: $scope.items.length, // length of data
getData: function($defer, params) {
var orderedData = params.sorting() ?
$filter('orderBy')($scope.items, params.orderBy()) : $scope.items;
orderedData = params.filter() ?
$filter('filter')(orderedData, params.filter()) : orderedData;
$scope.items = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());
params.total(orderedData.length); // set total for recalc pagination
$defer.resolve($scope.items);
}
});
这似乎非常适合过滤项目,因为
过滤到
但是,当我清除过滤器时,没有任何变化。我希望所有的行都重新出现,但他们没有。想法?