I have a scope array of locations, each location can be in one or more categories.
For eaxmple:
Locations: [{id: 1,
name: "NJ",
categories: [0, 2, 3]
},{
id: 2,
name: "NY",
categories: [0, 2]
}]
Categories: [{
id: 0,
name: "Cities"
}, {
id: 2,
name: "Canyons"
}, {
id: 3,
name: "Work"
}]
In my app I display all of the locations with this code:
<div ng-repeat="row in rows">
{{ row.name }}<br>
Categories: <span enum-categories="row"></span>
</div>
Now I want to add the option to group the items by their categories..
My problem is that each item can have more than one category..
The result need to be something like this:
cat 0:
NJ, NY
cat 1:
Nothing
cat 2:
NJ, NY
cat 3:
NJ
How can I do this?
Thank you :)