-2
下面是我的代碼ngtable分頁。下面是我的代碼ngtable分頁。在這個我的所有數據都加載在一個頁面中,即使我寫count:3和頁面:1
在此我所有的數據在一個頁面加載只有甚至我寫數:3頁:1
我怎麼能實現分頁。
這是我曾嘗試到現在:
var app=angular.module("app",["ngTable"]);
app.controller("ctrl",["$scope","NgTableParams",function($scope,NgTableParams)
{
$scope.user=[
{name:"anuradha",age:21,college:"NSIT"},
{name:"ABV",age:22,college:"IIT"},
{name:"ABCD",age:23,college:"KIT"},
{name:"anuradha",age:24,college:"GIT"},
{name:"POOJA",age:25,college:"SIT"},
{name:"ABC",age:26,college:"NT"},
{name:"abc",age:12,college:"abcd"},
{name:"qwe",age:22,college:"opqr"},
{name:"rty",age:45,college:"stiu"},
{name:"uio",age:14,college:"abcfgh"},
{name:"pas",age:19,college:"mnop"},
{name:"dfg",age:16,college:"qrst"},
];
$scope.table=new NgTableParams({page:1, count:3},{
counts: [],
total: $scope.user.length,
getData: function (params) {
return $scope.user.slice((params.page() - 1) *
params.count(), params.page() * params.count());
// console.log("user.length");
}});
}]);
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ng-table/1.0.0/ng-table.js"></script>
<body ng-app="app" ng-controller="ctrl">
<table ng-table="table" show-filter=true class="table table-bordered table-striped">
<tr ng-repeat="u in user">
<td title="'NAME'" >{{u.name}} </td>
<td title="'AGE'">{{u.age}}</td>
<td title="'COLLEGE'">{{u.college}}</td>
</tr>
</table>
</body>
,你的問題是什麼? –