-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(md-select) - enable to clear the value (unselect) #3110
Comments
We do want to add easy de-select functionality; it's on the list! In the meantime, you can get it to work with form reset: <md-select placeholder="My Option" [(ngModel)]="opt2" name="opt2" #model="ngModel">
<md-option (click)="model.reset()"></md-option>
<md-option value="item1">Item 1</md-option>
<md-option value="item2">Item 2</md-option>
</md-select> I've updated your plunker with an example. |
@kara thanks for the workaround. It worked like a charm. The only problem with this approach is that, when I have an undefined field in my ts file (not null), it assumes that the "empty" option is the one selected and the page is opened as if I had already selected an option. I've updated my plnkr with the above description. But for now, I can work it out by setting an out of domain value to the "empty" option. Thanks |
…tion Allows for options, with a value of `null` or `undefined`, to clear the select. This is similar to the way the native select works. Fixes angular#3110. Fixes angular#2634.
…tion Allows for options, with a value of `null` or `undefined`, to clear the select. This is similar to the way the native select works. Fixes angular#3110. Fixes angular#2634.
…tion Allows for options, with a value of `null` or `undefined`, to clear the select. This is similar to the way the native select works. Fixes angular#3110. Fixes angular#2634.
…tion Allows for options, with a value of `null` or `undefined`, to clear the select. This is similar to the way the native select works. Fixes angular#3110. Fixes angular#2634.
Compare two objects don't work.
|
I found that you can use
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
feat
What is the expected behavior?
In a md-select, let the user create a option to "unselect" the item value.
What is the current behavior?
When we add a empty option with value="" (ng-value="undefined" or ng-value="null"), the placeholder act as if we've selected an option
What are the steps to reproduce?
After selecting one option on md-select, try to "unselect" and revert it to the "empty" state
Providing a Plunker (or similar) is the best way to get the team to see your issue.
Plunker template: http://plnkr.co/edit/o077B6uEiiIgkC0S06dd
http://plnkr.co/edit/e8Qoaq7M1ubiWHpVKctu?p=preview
What is the use-case or motivation for changing an existing behavior?
Some non-required select on my applications need to let the user "unselect" the options
Which versions of Angular, Material, OS, browsers are affected?
@angular/material: 2.0.0-beta.1
Is there anything else we should know?
The text was updated successfully, but these errors were encountered: