-
Notifications
You must be signed in to change notification settings - Fork 27.5k
<select multiple ng-options> do not support default/empty option #4325
Comments
Removes a condition where static options are not added as part of render function when multiple attribute is enabled Closes angular#4325
Removes a condition where static options are not added as part of render function when multiple attribute is enabled Closes angular#4325
Here is the plunkr for the fix showing it works - http://plnkr.co/edit/jDijgjJ0EZLFUGIkTKDs?p=preview |
Confirmed! |
…ions Shows the static option for a not selected value in a select with ngOption also when the multiple attribute is used. Closes angular#4325 Closes angular#5938
Hi @martin-g, In a drop down box, you need an additional element to unselect a previously selected value. So why do you need that additional entry, what is your use case? |
Closing this for now. Please comment if you have a usecase that I overlooked. |
Hi @tbosch , I had to use it in a mobile/phone application. |
C'mon, don't ignore the UX for mobile applications! |
This change is not available in any version of angular js. Why so? |
@tbosch The unselect allows for nullable values if I have read the docs correctly. With multiple-select, the value is NOT nulled out when you deselect items. Instead it is set as an empty array. In my situation, I needed to check these element's models for null to display certain items on screen. Because multiple-select is not nullable, I had to set a $watch on the relevant model to null it out when the array is empty. That might be a valid use-case for allowing an option that is nullable in a multiple-select. Unless there is another way to do this better, it seems like a lot of trouble to set a $watch to null that value out |
Well, you could check for an empty array, right? |
Sure there are workarounds. Though in the context of what I was doing this in, I was using an ng-repeat with an ng-if to display several items from a model based on their value being null or populated. So it adds an extra, separate check for a very specific case because multi-select don't go to null. I'm sure there are better ways of accomplishing it and there are obviously easy ways around it, just throwing it out there as a possibility :) |
http://docs.angularjs.org/api/ng.directive:select shows an example (Color (null allowed)) of a select with ng-options and an option with empty value.
At http://plnkr.co/edit/dMKSt7P4ZPcWgBkpGvPI?p=preview I have an example that shows the functionality stops working if I add 'multiple' attribute to the select.
It also has plain select (not managed by Angular) that shows the empty value is supported for select.multiple.
The text was updated successfully, but these errors were encountered: