1
我試圖在ng-repeat上實現Bootstrap分頁。使用ng-repeat的AngularJs Bootstrap分頁不能正常工作
HTML
<tr data-ng-repeat="userDetails in data.slice(((currentPage-1)*itemsPerPage), ((currentPage)*itemsPerPage)) |filter:status:status.status" >
<td>{{userDetails.status.status}}</td>
<td> {{ userDetails.subDate | date : 'MM-dd-yyyy' }} </td>
<td> {{ userDetails.fullName }} </td>
<td> {{ userDetails.serviceType.serviceName }} </td>
<td> {{ userDetails.status.status }} </td>
</tr>
<select ng-model="viewby" ng-change="setItemsPerPage(viewby)"><option>5</option><option>10</option></select> records at a time.
<uib-pagination total-items="totalItems" ng-model="currentPage" ng-change="pageChanged()" class="pagination-sm" items-per-page="itemsPerPage"></uib-pagination>
JS
$http.get('getAlldetails').success(function(response)
{
$scope.data = response;
$scope.totalItems = $scope.data.length;
$scope.viewby = 10;
$scope.currentPage = 1;
$scope.itemsPerPage = $scope.viewby;
$scope.maxSize = 5; //Number of pager buttons to show
$scope.setPage = function (pageNo) {
$scope.currentPage = pageNo;
};
$scope.setItemsPerPage = function(num) {
$scope.itemsPerPage = num;
$scope.currentPage = 1;
}
})
問題是,如果我設置每頁10項,它示出了像在第一頁7項,在9項的項的隨機數下一頁並繼續。我嘗試添加ui-bootstrap-tpls.js,但沒有運氣。
有你有機會來嘗試解決以下建議? – sheilak