我在刷新ngTableParams方面遇到了麻烦

时间:2021-04-09 22:25:08

I can't seem to figure out the refresh. I can get the intial load of the page, but when the function getActivity() is run it doesn't update the page. At a loss. Tried many different things but to no success.

我似乎无法弄清楚刷新。我可以获得页面的初始加载,但是当运行getActivity()函数时,它不会更新页面。不知所措。尝试了许多不同的事情,但没有成功。

This code below is being called from a factory

以下代码是从工厂调用的

uaAppCommon.tableParams = function(data,sortFieldOrder){
        var table = new ngTableParams({
             //page: 1,            // show first page
             count: data.length,          // count per page
             sorting: sortFieldOrder
         }, {
            counts: [],  //hides page sizes
             total: data.length, // length of data
             getData: function($defer, params) {
                 // use build-in angular filter
                 var orderedData = params.sorting() ?
                                     $filter('orderBy')(data, params.orderBy()) :
                                     data;
                 $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
             }
         });
        return table;
    };

This snippet is the calling function within the controller.

此代码段是控制器中的调用函数。

$scope.getActivity = function(numDays){
        appService.loadActivity(numDays)
        .then(function(response){
            var activity = appService.getActivity();
            $scope.activityTable = appCommon.tableParams(activity,{date: 'desc'});  
        });
    };

This is the HTML:

这是HTML:

<table ng-table="activityTable" class="table" fixed-table-headers="scrollable-area">
                            <tr ng-repeat="act in $data">
                                <td data-title="'Date & Time'" sortable="'date'">
                                    {{act.date}}
                                </td>
                                <td data-title="'Activity'" sortable="'activity'">

1 个解决方案

#1


1  

Can you provide plunker? Can you check this line in your controller $scope.activityTable = appCommon.tableParams(activity,{date: 'desc'}); try replacing it with $scope.activityTable = uappCommon.tableParams(activity,{date: 'desc'});

你能提供plunker吗?你可以在你的控制器$ scope.activityTable = appCommon.tableParams(activity,{date:'desc'})中查看这一行吗?尝试用$ scope.activityTable = uappCommon.tableParams(activity,{date:'desc'})替换它;

and if that doesn't work reload your table yourtablename.reload() after your function gets called.

如果这不起作用,请在调用函数后重新加载表yourtablename.reload()。

#1


1  

Can you provide plunker? Can you check this line in your controller $scope.activityTable = appCommon.tableParams(activity,{date: 'desc'}); try replacing it with $scope.activityTable = uappCommon.tableParams(activity,{date: 'desc'});

你能提供plunker吗?你可以在你的控制器$ scope.activityTable = appCommon.tableParams(activity,{date:'desc'})中查看这一行吗?尝试用$ scope.activityTable = uappCommon.tableParams(activity,{date:'desc'})替换它;

and if that doesn't work reload your table yourtablename.reload() after your function gets called.

如果这不起作用,请在调用函数后重新加载表yourtablename.reload()。