I have an object called groupList that looks like this:
{
"12777e85-c03a-97ba-42ce-3242b6bd4109": {
"id": "12777e85-c03a-97ba-42ce-3242b6bd4109",
"name": "uber name for group"
},
"57415d36-e935-cc6a-11b4-0b95bce5cb95": {
"id": "57415d36-e935-cc6a-11b4-0b95bce5cb95",
"name": "a group name"
},
"65c9cf1d-0876-1faf-7986-e44bbba8d0fe": {
"id": "65c9cf1d-0876-1faf-7986-e44bbba8d0fe",
"name": "users"
},
"d3525828-0b53-a7eb-6c17-ea142a54687e": {
"id": "d3525828-0b53-a7eb-6c17-ea142a54687e",
"name": "admin"
}
}
And I'm trying to use that in a select box. I can ng-repeat through the data with no problem simply by doing ng-repeat="group in groupList
but that doesn't work as well for ng-option. I'm getting precariously close with: ng-options="name for (id, name) in groupList"
where groupList is the object that I'm working against. I'm just not quite there.
Any ideas?
You were close, is this what you are after?
<select ng-options="key as value.name for (key, value) in groupList" ng-model="selected"/>