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.
Repository navigation
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
<select multiple ng-options> do not support default/empty option #4325
Hi @martin-g,
as I think over it, this does not make sense.
In a drop down box, you need an additional element to unselect a previously selected value.
However, in a multiple select, you are able to unselect any element by pressing Ctrl+Click (Windows) or Command+Click (Mac). This should work in any browser and is the default behavior of HTML.
So why do you need that additional entry, what is your use case?
@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
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 :)
Activity
martin-g commentedon Oct 8, 2013
This issue may be related to #3337 and #3230
fix(ngSelect): Support static options on multi-select drop down
fix(ngSelect): Support static options on multi-select drop down
siddii commentedon Jan 22, 2014
Here is the plunkr for the fix showing it works - http://plnkr.co/edit/jDijgjJ0EZLFUGIkTKDs?p=preview
martin-g commentedon Jan 22, 2014
Confirmed!
Looks as desired!
fix(ngSelect): Support not selected option on multi select with ngOpt…
tbosch commentedon Feb 6, 2014
Hi @martin-g,
as I think over it, this does not make sense.
In a drop down box, you need an additional element to unselect a previously selected value.
However, in a multiple select, you are able to unselect any element by pressing Ctrl+Click (Windows) or Command+Click (Mac). This should work in any browser and is the default behavior of HTML.
So why do you need that additional entry, what is your use case?
tbosch commentedon Feb 6, 2014
Closing this for now. Please comment if you have a usecase that I overlooked.
martin-g commentedon Feb 6, 2014
Hi @tbosch ,
I had to use it in a mobile/phone application.
It is not so easy to use Ctrl there.
martin-g commentedon Feb 10, 2014
C'mon, don't ignore the UX for mobile applications!
tbosch commentedon Feb 10, 2014
Hi,

mobile browsers have their own UI for select multiple.
I didn't check older browsers. If they don't do what you need you would need to create a workaround for them, as this would be a browser bug.
geekmj commentedon May 8, 2014
This change is not available in any version of angular js. Why so?
bretongoers commentedon Jun 25, 2014
@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
tbosch commentedon Jun 25, 2014
Well, you could check for an empty array, right?
bretongoers commentedon Jun 25, 2014
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 :)