Mirko
Mirko

Reputation: 137

How to do a nested group by in angular js

I'm trying to do a group by for a select element with angular js,starting from this json file:

 [ { city:'Casacanditella', region: 'Abruzzo' ,
id: 19,name: 'museo prova' },
{ city'Archi', region: 'Abruzzo',
id: 20,name: 'Museo aperto' }]

What I want is to have the element displayed in this way

so grouped by region and then by city. How can i do it ? I've tried to do something like this

ng-options="m.museumName group by (m.region and m.city ) for m in museum"

It's obviously wrong,but in practice is what I expect to see. Thanks in advance for the help!

Upvotes: 1

Views: 166

Answers (1)

kmhigashioka
kmhigashioka

Reputation: 521

Hmmm. Im not sure if it is possible to do group by on select tag by twice. But I made string manipulation on grouping by.

ng-options="museum.name group by museum.region + ' ' + museum.city for museum in museums"></select>

Here is a plnkr

Upvotes: 1

Related Questions