[英]Increment a line number using angular js
How to increment a line number in AngularJS?? 如何在AngularJS中增加行号?
$scope.line = 1;
$scope.next = function(){
.....;
.....;
.....;
$scope.line++;
};
I am using it as Line:{{line}}
我将其用作Line:{{line}}
But every element gets the same number. 但是每个元素都有相同的数字。 What should I do here contain them in an array and display them using repeat or is there any better way? 我在这里应该怎么做才能将它们包含在数组中,并使用重复显示它们?是否有更好的方法?
ng-repeat
provides access to array index of instance as $index
in each child scope ng-repeat
提供在每个子作用域中以$index
访问实例的数组索引
Could try 可以尝试
<div ng-repeat="item in items">
Line: {{$index+1}}
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.