Javascript 角度表分页中增量序列号的获取
我使用角度表分页。我有一个序列号,每一页从1开始,但我想要连续的页码。如何得到它Javascript 角度表分页中增量序列号的获取,javascript,jquery,angularjs,pagination,Javascript,Jquery,Angularjs,Pagination,我使用角度表分页。我有一个序列号,每一页从1开始,但我想要连续的页码。如何得到它 <div ng-app="myApp" ng-controller="myController"> <table id="myData"> <thead> <td>S.no</td> <td>Name</td> <td>Age
<div ng-app="myApp" ng-controller="myController">
<table id="myData">
<thead>
<td>S.no</td>
<td>Name</td>
<td>Age</td>
</thead>
<tbody>
<tr dir-paginate="data in details | itemsPerPage:3">
<td>{{$index+1}}</td>
<td>{{data.name}}</td>
<td>{{data.age}}</td>
</tr>
</tbody>
</table>
</div>
序号
名称
年龄
{{$index+1}}
{{data.name}
{{data.age}
完整代码:
如果我尝试:
<td>{{itemsPerPage * (currentPage - 1) + $index + 1}}</td>
{{itemsPerPage*(当前页面-1)+$index+1}
它正在返回
null
。有什么建议吗?计算索引的公式是正确的,但您没有正确初始化变量:
app.controller('myController', function($scope) {
$scope.itemsPerPage = 3;
$scope.currentPage = 1;
$scope.details = [{
...
}];
}
<tr dir-paginate="data in details | itemsPerPage:itemsPerPage" current-page="currentPage">
<!-- now you can use itemsPerPage and currentPage to calculate index value -->
<td>{{($index + 1) + (currentPage - 1) * itemsPerPage}}</td>
</tr>
我在中更新了jQuery版本,现在应用程序运行良好。非常感谢:-)它运行良好:-)您能告诉我,为什么我们不需要添加此
currentPage=“currentPage”
以及当我们单击页面时,$scope.currentPage
是如何自动更改的?@laz当前页面
是一个指令属性,其工作方式类似于getter和setter-。您可以在控制器$scope.currentPage
中指定一个属性,并使用它获取和设置当前分页页面。
angular.module('myApp', ['angularUtils.directives.dirPagination']);