我已经看过很多类似的问题,但尝试了各种解决方案,似乎无法使其中任何一个工作。
宣布参数的函数:
$scope.customers = [];
$http.post("http://api.dev/v1/customers/search", $scope.searchData)
.then(function (response) {
$scope.customers = response.data;
$scope.tableParams = new ngTableParams({
page: 1, // show first page
count: 10, // count per page
}, {
total: $scope.customers.length, // length of data
getData: function ($defer, params) {
var orderedData = params.sorting() ?
$filter('orderBy')($scope.customers, params.orderBy()) :
$scope.customers;
$defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
}
});
HTML:
<table class="table ng-table-rowselected" ng-table="tableParams" >
<thead>
<th>Customer</th>
<th>Company</th>
<th>Name</th>
<th>Start Date</th>
<th>Status</th>
</thead>
<tbody>
<tr ng-repeat="cust in customers"
ng-click="cust.$selected = !cust.$selected; changeSelection(cust)"
ng-class="{'active': cust.$selected}">
<td data-title="'company'" >{{cust.custref}}</td>
<td data-title="'company'" >{{cust.company}}</td>
<td data-title="'address'" > {{cust.firstname}} {{cust.lastname}}</td>
<td data-title="'startdate'" > {{cust.startdate}}</td>
<td data-title="'status'"> {{cust.status}}</td>
</tr>
</tbody>
</table>
当我单击搜索按钮时,会显示所有数据,显示分页按钮和页数,但单击它们时它们没有任何影响。我不知道我做错了什么,任何帮助都会受到赞赏。