如何用ng-table angular实现分页?

时间:2017-12-17 22:13:18

标签: angularjs sorting pagination

我有一组数据,我试图加载到表中,我得到的只是控制器,表格一次显示所有记录,没有分页。有人可以帮忙吗?

<table ng-table="assignmentsTable">

                        </table>
$scope.dashboard = function (filter) {
    /* the $http service allows you to make arbitrary ajax requests.
    * in this case you might also consider using angular-resource and setting up a
    * User $resource. */
    //var filter = 'LAST_WEEK';
    var postData = {data : filter, state: ['All']};

    $http.post('/isystem/manage/getassign2.php', postData)
        .then(function successCallback(response) {
            $scope.Dashboard_Data = response.data.DATA[filter];
            $scope.assignmentsTable = new NgTableParams({
                page: 1,
                count: 15
            }, {
                total: $scope.Dashboard_Data.length, 
                getData: function ($defer, params) {
                    $scope.data = params.sorting() ? $filter('orderBy')($scope.Dashboard_Data, params.orderBy()) : $scope.Dashboard_Data;
                    $scope.data = $scope.Dashboard_Data.slice((params.page() - 1) * params.count(), params.page() * params.count());
                    $defer.resolve($scope.data);
                }
            });

            console.log("Assignments Data: " + $scope.Dashboard_Data);
        }, function errorCallback(response) {
            console.log(response);
    });
}

非常感谢任何帮助......谢谢。

0 个答案:

没有答案