【发布时间】:2014-08-14 14:07:41
【问题描述】:
我正在使用 ui-Bootstrap 分页,但它没有按预期工作,我参考了以下帖子,但它对我不起作用。
How do I tell ui-Bootstrap what content to paginate?
我的代码如下。
<div>
<ul>
<li ng-repeat= "payment in paymentHistory">
<div >
<div >
<p >payment.status</p>
</div>
<div>
<p >payment.cost</p>
</div>
</div>
</li>
</ul>
</div>
<div ng-show="pagination"> <pagination total-items="totalItems" items-per-page="itemsPerPage" ng-model="currentPage" ng-change="pageChanged()"></pagination></div>
我的控制器代码:
paymentFactory.getPaymentHistory( )
.success(function (paymentHisInfo) {
for(var i = 0; i< paymentHisInfo.list.length; i++){
$scope.paymentHistory.push({
"status":paymentHisInfo.list[i].status,
"cost":paymentHisInfo.list[i].cost});
}
$scope.list = $scope.paymentHistory;
$scope.itemsPerPage = 5;
$scope.currentPage = 1;
$scope.pageCount=Math.ceil($scope.list.length / $scope.itemsPerPage);
$scope.list.$promise.then(function () {
$scope.totalItems = $scope.list.length;
var begin = (($scope.currentPage - 1) * $scope.itemsPerPage),
end = begin + $scope.itemsPerPage;
$scope.paymentHistory = $scope.list.slice(begin, end);
});
})
.error(function(){
console.log("error occured in getPaymentHistory");
});
Please let me know whats wrong in my code
【问题讨论】:
-
这是我的错……我的代码中有输入。我更新了运行良好的代码。
-
你应该回答你自己的问题或删除这个问题。
标签: pagination angular-ui-bootstrap