0

I have set up an ngTable and the following tableParams:

var selectedItems = []; $scope.tableParams = new ngTableParams({ page: 1, // show first page count: 5 // count per page }, { total: selectedItems.length, // length of data getData: function ($defer, params) { $defer.resolve(selectedItems.slice((params.page() - 1) * params.count(), params.page() * params.count())); } });

The content of "selectedItems" is updated via a $scope.$watch that monitors the users selection from another "screen" in the single page application. However, after the user makes their selection, the "count" property in the tableParams is being ignored and it is displaying all 15 rows with no pagination options.

4

1 回答 1

2

我在 ngTable 分页上遇到了类似的问题,对于那些有同样问题的人,修复方法是$data在指令中引用 ngTable 范围ng-repeat(无论您在哪里/如何存储表数据)。

IE<tr ng-repeat="item in $data">

似乎$defer.resolve()会将表数据(即selectedItems)分配$data给观察模型突变的范围 - 这很棘手,因为引用selectedItems仍然ng-repeat显示数据(只是没有分页!)。

于 2014-09-10T04:28:31.327 回答