You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
I'm not really sure if this is a bug or just me not using Angular properly.
I have a select that is not using ng-options, instead I'm using ng-repeat to iterate over a list of hashes to create my own optgroup and options. The problem is that my my empty options with value="" gets set to selected.
By messing around a little bit in the debugger I can see that the options are not processed at the time that the select directive is trying to set the right options to selected. It consults the optionMap which is empty at the time which causes the empty option to be selected.
My speculation (currently based on zero knowledge about how watch is used in this case) is that a watch is always triggered once. At this stage we have no added options yet so the watched expression gets set to the current value and the empty option is selected. After that the inside of the select is processed (compiled) I think which causes the options to be added to their containing select controller. Now if the select controller was re-rendered it would probably work to set the selected status. However now the watch already thinks it has updated the view to the correct state because it already called render and the value it rendered has not changed since.