In my data object, I have key-value pairs where the value is an array. Each array contains objects with various properties.
$scope.testObj = {
"London":[
{"id":1,"city":"London","country":"GB","name":"Test1"},
{"id":4,"city":"London","country":"GB","name":"Test2"}
],
"Los Angeles":[
{"id":8,"city":"LA","country":"US","name":"Test3"}
]
}
My goal is to display the names next to the respective cities in the frontend using Angular. I've tried multiple approaches, including using track by $index, but I'm struggling to make it work.
<div ng-repeat="(key, val) in jobsByCity track by $index">
{{key}}:{{val[$index].name}}
</div>
I've also experimented with nested ng-repeat as shown below:
<div ng-repeat="(key, val) in testCity">
{{key}}
<div ng-repeat="test in val[$index].name">
{{test}}
</div>
</div>