I have an angular dropdown which contains this data:
.constant('colors', {
1 : red,
2 : blue,
3 : yellow
})
and I have a dropdown which looks like this:
ng-options="key as key for (key, value) in colors"
This selection is in modal window. It works correctly, so the selected value is correctly represented in model.
However, when I reopen the modal window, dropdown always defaults to the default value, ignoring previously selected value.
Can anybody hlep me fix this, please?
Also, is it possible to display both key and value in the dropdown? So instead of dropdown like: 1, 2, 3 I want something like 1 - red, 2 - blue, 3 - yellow. Also, I do not want to display color names only, because I need the numbers.
Thanks in advance guys!
ng-options="key as (key+' - '+value) for (key, value) in colors". Can you also add the code which is suppose to save your variable which is use when you reopen the modal ?