gpt4 book ai didi

javascript - dir-paginate angularJs 创建的每个表行的行号

转载 作者:行者123 更新时间:2023-11-30 11:51:36 26 4
gpt4 key购买 nike

如何为 dir-paginate angularJs 创建的每个表行设置行号。我使用两种方式的代码,但两种方式都有不正确和设置错误。

第一种方式:

    <tr dir-paginate='customer in Customers| itemsPerPage: 10'>
<td>{{rowNum=(rowNum+1)}}</td>
<td>{{customer.fName}}</td>
<td>{{customer.lName}}</td>
</tr>

<script>
(function(){
var app = angular.module('customerApp', ['angularUtils.directives.dirPagination']);
app.controller('customer', ['$scope', '$http', function($scope, $http){
$scope.rowNum = 1;
}]);
})();
</script>

第二种方式:

<tr dir-paginate='customer in Customers| itemsPerPage: 10'>
<td>{{getRowNum()}}</td>
<td>{{customer.fName}}</td>
<td>{{customer.lName}}</td>
</tr>

<script>
(function(){
var app = angular.module('customerApp', ['angularUtils.directives.dirPagination']);
app.controller('customer', ['$scope', '$http', function($scope, $http){
$scope.rowNum = 1;
$scope.getRowNum = function(){
return ++$scope.rowNum;
};
}]);
})();
</script>

为什么我不能从函数和 ng-bind 中增加 $scope.rowNum

最佳答案

我认为 {{$index+1}} 应该可行

带有索引 + 分页的图像 -> {{(currentPage-1)*pageSize +$index+1}} enter image description here

关于javascript - dir-paginate angularJs 创建的每个表行的行号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39285818/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com