What's the best way for ng-options=""
to iterate over JSON objects without ng-repeat=""
...
in order to retrieve all values.
$scope.examples =
[
{"name":"parent 1",
"subs": [
{"name":"child a", "id":"1a"},
{"name":"child b", "id":"1b"}
]
},
{"name":"parent 2",
"subs": [
{"name":"child a", "id":"2a"},
{"name":"child b", "id":"2b"}
]
}
];
Should return, 1a, 1b, 2a, 2b for the <option>
rendered in a single <select>
I mistakenly thought something like...
<select ng-model="data.sub" ng-options="item.id for item in examples.example.subs"></select>
...would iterate over sub objects. Do I need a separate function? Scope definition of some sort? Any help is appreciated.