In ngTables, running $scope.tableParams.reload() for the third time results in TypeError: Cannot set property '$data' of null

不羁岁月 提交于 2019-11-30 22:20:01

I know this is too late, but I thought better to comment on this for others who seeking for a answer for the same issue.

I also had the same issue and managed to fix by following the example in following URL.

https://github.com/esvit/ng-table/blob/master/src/scripts/04-controller.js

I just added the following code line into my code after 'ngTableParams' instance creation.

$scope.params.settings().$scope = $scope;

Try adding:

,
$scope: { $data: {} }

after:

getData: function($defer, params) {
                data = transactions;
                var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data;
                $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));

            }

I had the same problem. When you initialize ngTableParams, you need to specify all parameters: page, count, total, and counts, even if you are not using paging, because otherwise the $scope property of setting will be set to null somehow during merging all settings together.

Moin Khan

I also faced the same problem and solved it by adding reload:

$scope.tableParams as below 
$scope.tableParams = new ngTableParams({
            page: 1,
            count: 25,
            ***reload: $scope.tableParams***
        },
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!