I have a set of JSON data structured like this:
[
{
"id": 1,
"address": "MG Road",
"country": INDIA,
"state": AP,
"city": VIJ
},
{
"id": 2,
"address": "Miyapur",
"country": INDIA,
"state": TS,
"city": HYD
},
{
"id": 3,
"address": "Autonagar",
"country": INDIA,
"state": AP,
"city": VIJ
},
{
"id": 4,
"address": "Kukatpalli",
"country": INDIA,
"state": TS,
"city": HYD
},
{
"id": 5,
"address": "Koti",
"country": INDIA,
"state": TS,
"city": HYD
}
]
My goal is to display the data in the following format:
IND,TS,HYD
Miyapur, Koti, Kukatpalli
IND,AP,VIJ,
MG Road, Autonagar
To achieve this, I attempted to use the groupBy filter, but encountered issues in grouping the values.
This is the code I tried:
<div class="location-container">
<label ng-repeat="(key,value) in locationmodel | groupBy: '[country,state,city]'">{{key}}
</label>
<span ng-repeat="location in value">{{location.address}}</span>
</div>
Unfortunately, the above code did not produce the desired outcome. Any assistance in resolving this issue would be greatly appreciated.
Thank you in advance.