Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

feat(select): changed md-select to have select all feature #7674

Closed
wants to merge 1 commit into from

Conversation

praskarnam
Copy link

@gmoothart @ErinCoughlan @jelbourn @ThomasBurleson , Please review.

The multi select component of angular material does not have the below

  • Select All
  • When there are more than 1 selected then it keeps adding all of them to the selected label hence growing the component in size. Missing a label saying XX +n more as selected.

This commit adds the above functionality to the select component.

The below code shows how a md select can be written the feature of check all

      <md-input-container style="width:200px;">
        <label>State</label>
        <md-select ng-model="userState1" multiple id="hello" select-all>
          <md-option ng-repeat="state in states" value="{{state.abbrev}}" select-all>
            {{state.abbrev}}
          </md-option>
        </md-select>
      </md-input-container>

If you notice there is a attribute select-all which is added to the md-select which would add the check all option. Further you can see that the same attribute is added to the md-option to just display the check box for all the options. Adding to the md-option is optional where are adding to the md-select is required. The output would be as below

selectall-1

selectall-2

use now attribute select-all in the md-select for select all option in the drop down.

```html
<md-select ng-model="userState1" multiple id="hello" select-all>
```
@ErinCoughlan
Copy link
Contributor

@praskarnam This will be possible with the new changes to select currently in progress.

Adding checkboxes to each item in the multiple select case is PR #7455, which was already merged to master.

Allowing custom selected text (like "AL [+49 more]") is PR #7721, which also allows custom text like "Select your state" when the select is closed.

Adding custom header information, like a searchbar or select-all/none functionality is Issue #7383, which is in progress. Material UX has not specified how "select all/none" should appear, so that adds more flexibility for devs to customize it to their apps, for instance by adding a "Check All" checkbox above the item content, like you did here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants