I'm getting a strange behavior when binding the following object to a select
:
REGIONSH = {0:"All Regions",1:"Europe",2:"North America"};
HTML (where region
is a integer for key):
<select ng-model="REGIONSH[region]" ng-options="name for(key,name) in REGIONSH">
The behavior is that the list is populated correctly with the correct option selected, but when I change the region
variable the selected entry changes fine, but suddenly both the original and the new selections are named the same thing.
For example, I would select the second element in the list, and the original one would be renamed to "North America" from "All Regions".
The desired behavior is to have a select where I can chose from each of the values in the object while having the key as the option
's value.
ng-model
to just the integer (which happens to also be the index) I just get an empty option with?
as the value.ng-model
recursively, whereas it should maybe just beng-model="region"
. Plunker is that what you're talking about?