I'm currently facing a challenge with a seemingly simple task: I have an array of string values that I want to link to a select
element's option
s, and then connect the index of the chosen value to a variable. However, I have found that neither using ng-options
nor regular options
with ng-repeat
fully accomplishes this task. The latter method works only after selecting some values, but does not bind with the initially set value when the page is loaded.
You can see an example of this issue in action on Codepen: http://codepen.io/modo_lv/pen/xGYQjM (click on "View Compiled" to view the pure HTML and JavaScript code). Pay attention to how both dropdowns are initially empty despite having a pre-set value. Additionally, selecting an option in the first dropdown results in unsetting the initial value.