I have a JSON object that contains a map of values. The keys of these map item are predefined. I use ng-repeat to create a button for each map item and I pass the item to the method via ng-click.
To execute a certain call, I now need the key of the item. How can I get the key of the given item?
The JSON looks like
"map": {
"0": {
"id": 1,
"value": "123",
},
"1": {
"id": 5,
"value": "567",
}
}
.html
<div ng-repeat="item in object.map">
<button ng-click="load(item)" type="button">A</button>
</div>
app.js
$scope.load= function(item) {
// HOW TO GET THE KEY OF THE GIVEN MAP ITEM
};