I'm guessing it's because you constantly change the original array. That is, $scope.items first contains all items. Then you filter, and modify $scope.items by removing items that no longer match. When you clear the filter, $scope.items only contains the items that matched the last filter.
You start out by taking $scope.items and running a filter on it, and then assign that to orderedData. Then you assign $scope.items to orderedData which is why the size of $scope.items is just getting smaller and smaller.
Try changing it to:
$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;
orderedData = orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count());
params.total(orderedData.length); // set total for recalc pagination
$defer.resolve(orderedData);
}
});
And your ng-repeat
to:
<tr ng-repeat="item in $data">
As ngTable seems to add a $data property on the scope with the filtered data.