For example lets take an array example
$scope.users = ['John','Peter'];
How to get the index of John ?
For example lets take an array example
$scope.users = ['John','Peter'];
How to get the index of John ?
$scope.users.indexOf('John')
This is not angular specific. This is a JS array method.
try this in your view html {{users.indexOf('John')}}
or in your controller use $scope.users.indexOf('John')
Use track by $index
.
E.g. <p ng-repeat = "user in $scope.users track by $index"></p>
Then you can determine if it's John:
<p ng-repeat = "user in $scope.users track by $index">
<span ng-if="$scope.users[$index] === 'John'">Here's John at {{$index}}</span>
</p>