I have read about it in other posts, but I couldn\'t figure it out.
I have an array,
$scope.items = [
{ID: \'000001\', Title: \'Chicago\'},
{ID
For some reason AngularJS allows to get me confused. Their documentation is pretty horrible on this. More good examples of variations would be welcome.
Anyway, I have a slight variation on Ben Lesh's answer.
My data collections looks like this:
items =
[
{ key:"AD",value:"Andorra" }
, { key:"AI",value:"Anguilla" }
, { key:"AO",value:"Angola" }
...etc..
]
Now
still resulted in the options value to be the index (0, 1, 2, etc.).
Adding Track By fixed it for me:
I reckon it happens more often that you want to add an array of objects into an select list, so I am going to remember this one!
Be aware that from AngularJS 1.4 you can't use ng-options any more, but you need to use ng-repeat
on your option tag: