1

How to increment a line number in AngularJS??

$scope.line = 1;
$scope.next = function(){
  .....;
  .....;
  .....;
  $scope.line++;
};

I am using it as 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?

1
  • could you show some more code please Commented Jul 15, 2016 at 14:57

1 Answer 1

5

ng-repeat provides access to array index of instance as $index in each child scope

Could try

<div ng-repeat="item in items">
   Line: {{$index+1}}    
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.