Suppose I have an array named "stuff" with the following elements
$scope.stuff = [
{name: "one", order: 1},
{name: "three", order: 3},
{name: "two", order: 2}
]
When I use ng-repeat
to display it:
<div ng-repeat="(key, data) in stuff | orderBy:'-order'">
{{ data.name }} - {{ key }} - {{ $index }}
<br />
</div>
The output will be:
1 - 0 - 0
2 - 1 - 1
3 - 2 - 2
I want to know the original position of each item in the actual array $scope.stuff
, not just its index in the sorted ng-repeat
.
As a beginner in Angular, can anyone provide suggestions on how to achieve this?