【发布时间】:2016-09-02 06:38:49
【问题描述】:
如何为 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?
【问题讨论】:
-
你能给我们提供一个codepen oder fiddlejs示例吗?
标签: javascript angularjs dirpagination