Your states
is structured as an array containing a single object with state key/value pairs. Even though an object can be used with ng-options
, it's unclear why an array is necessary. You can still reference the source object using "... in states[0]"
.
Additionally, ng-options
mandates an ng-model
to be included.
<select ng-model="selectedState"
ng-options="key as state for (key, state) in states[0]">
</select>
In the code snippet above, selectedState
will be assigned the value of key
(the abbreviation). It can also be assigned the value of state
.
If the states
array doesn't need to be a single-element array and instead directly represents the object, you can reference it as "...(key, state) in states"
instead of ... in states[0]"
.