Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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.
Add a comment
try this in your view html {{users.indexOf('John')}} or in your controller use $scope.users.indexOf('John')
{{users.indexOf('John')}}
Use track by $index.
track by $index
E.g. <p ng-repeat = "user in $scope.users track by $index"></p>
<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>
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.