-
Notifications
You must be signed in to change notification settings - Fork 27.4k
select chooses wrong option when ng:repeat used inside select #639
Comments
This is why ng:options exists in the first place. For months we tried to get ng:repeat to work within the select element, but we could never get it right and all the hacks we needed to create an illusion of this working were really polluting the angular code base. I'd go as far as throwing an exception when you try to use ng:repeat on an option element, but in some simple cases, the current behavior is good enough. The whole thing comes down to issues like the repeater unrolling too late and select trying to pick an option too early. There was some other stuff as well that I can't remember now. |
This is old but still seems to be a problem. I am now using 1.0.2 and am having this exact same problem. I have this: <select name="license_year" ng-options="license_year for license_year in license_year_list" ng-model="item.license_year"></select> license_year_list is just a plain array (eg): [1990, 1991, 1992, ...] I know the binding works, because when I select a year, item.license_year is updated. But when the select list is first displayed, no value is selected, even though there is an option for the value of item.license_year. The exact same behavior as esprehn, and I am using ng-options, exactly like you say! Do I need to generate the options explicitly and then mark the initial selected option? |
Closing this issue, as the problem no longer exists when using ngOptions. |
will show the first element as selected, even though the ng:model bound value is different. If you interact with the select and start selecting values to change the bound value it will become resynchronized with the model. http://jsfiddle.net/GTynf/3/ Verified in both Webkit and Firefox, this isn't browser specific.
The text was updated successfully, but these errors were encountered: