I receive JSON data from an API in the following format:
$scope.data = [{
"primary": "white",
"sub": ["white 1", "white 2", "white 3"]
},{
"primary": "black",
"sub": ["black 1", "black 2", "black 3"]
}];
My goal is to group by the primary key and have the selectable values be the sub arrays.
For example:
**White**
white 1
white 2
white 3
**Black**
Black 1
Black 2
Black 3
I have successfully grouped by the primary key, but I am struggling to display the inner values. Here's what I currently have:
<div ng-controller="myCtrl">
<select
ng-model="myOption"
ng-options="val.primary group by value.primary for value in data">
</select>
<div>
ng-model value: {{myOption}}
</div>
</div>
(You can also view my code on this fiddle: http://jsfiddle.net/jm6of9bu/648/)