i have page with ng-table which works fine with initial data. I have a select box which send server request based on the option selected and then Iam getting new data to angular but is not updated with ng-table.
Here is my view:
{{column.title}} {{user[column.field]}}
My controller:
angular.module('reports').controller('ReportsController', ['$scope', '$stateParams', '$location', 'Authentication', 'Reports', '$filter', 'ngTableParams', function($scope, $stateParams, $location, Authentication, Reports, $filter, ngTableParams ) { $scope.reportBillingPeriod = 0; $scope.$watch('reportBillingPeriod', function(newValue, oldValue) { $scope.findReportData( newValue ); }); //$scope.reportBillingData = 0; $scope.findReportData = function( selectedMonth ){ var selectedPeriod = selectedMonth; if( selectedPeriod === null ) selectedPeriod = '0'; $scope.customers_report = Reports.customer_report({ monthReport: selectedPeriod }, function( result ){ var data = result.customers; $scope.columns = [ { title: 'Account Name', field: 'accountName', visible: true, filter: { 'name': 'text' } }, { title: 'Gross Revenue', field: 'planTotalAmount', visible: true } ]; $scope.$watch('result', function () { $scope.tableParams.settings().$scope = $scope; $scope.tableParams.reload(); }); $scope.tableParams = new ngTableParams({ page: 1, // show first page count: 10, // count per page filter: { name: 'O' // initial filter } }, { total: data.length, // length of data getData: function($defer, params) { var orderedData = params.sorting() ? $filter('orderBy')(data, params.orderBy()) : data; $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count())); //$scope.reportBillingData = new Date(); } }); }); }; }]);