Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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

Closed

Description

@martin-g

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.

Activity

  1. martin-g commented on Oct 8, 2013

    @martin-g
    Author

    This issue may be related to #3337 and #3230

  2. added 2 commits that reference this issue on Jan 22, 2014
    6f28f50
    db96f77
  3. siddii commented on Jan 22, 2014

    @siddii
    Contributor

    Here is the plunkr for the fix showing it works - http://plnkr.co/edit/jDijgjJ0EZLFUGIkTKDs?p=preview

  4. martin-g commented on Jan 22, 2014

    @martin-g
    Author

    Confirmed!
    Looks as desired!

  5. self-assigned this
    on Feb 6, 2014
  6. added a commit that references this issue on Feb 6, 2014
    73e73d0
  7. tbosch commented on Feb 6, 2014

    @tbosch
    Contributor

    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?

  8. tbosch commented on Feb 6, 2014

    @tbosch
    Contributor

    Closing this for now. Please comment if you have a usecase that I overlooked.

  9. removed their assignment
    on Feb 6, 2014
  10. martin-g commented on Feb 6, 2014

    @martin-g
    Author

    Hi @tbosch ,

    I had to use it in a mobile/phone application.
    It is not so easy to use Ctrl there.

  11. martin-g commented on Feb 10, 2014

    @martin-g
    Author

    C'mon, don't ignore the UX for mobile applications!

  12. tbosch commented on Feb 10, 2014

    @tbosch
    Contributor

    Hi,
    mobile browsers have their own UI for select multiple.
    iOS7 select multiple

    Android 4.4 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.

  13. geekmj commented on May 8, 2014

    @geekmj

    This change is not available in any version of angular js. Why so?

  14. bretongoers commented on Jun 25, 2014

    @bretongoers

    @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

  15. tbosch commented on Jun 25, 2014

    @tbosch
    Contributor

    Well, you could check for an empty array, right?

  16. bretongoers commented on Jun 25, 2014

    @bretongoers

    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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions