I have an array full of parent objects, and nested in each parent object I have an array with child objects. Without rebuilding my model I'm struggling to find the best way to use angular-ui-select to achieve a dropdown select box with grouping enabled.
$scope.allCategories = [
{
"code": "AAAA",
"name": "animals",
"categories": [
{
"code": "APET",
"name": "pets"
},
{
"code": "ASUP",
"name": "supplies"
},
{
"code": "AOTH",
"name": "other"
}
]
},
{
"code": "CCCC",
"name": "community",
"categories": [
{
"code": "CCNW",
"name": "classes and workshops"
},
{
"code": "COMM",
"name": "events"
},
{
"code": "CGRP",
"name": "groups"
}
]
}
]
Here's what I've built so far, but I need the many features angular-ui-select has without reinventing the wheel.
<select class="form-control">
<optgroup ng-repeat="category in allCategories" label="{{category.name}}">
<option ng-repeat="childCategory in category.categories" value="{{childCategory.code}}">{{childCategory.name}}</option>
</optgroup>
</select>