md-select does not display default (null) option text in mat-select-value
See original GitHub issueBug, feature request, or proposal:
Bug
What is the expected behavior?
Select should display text associated with null/undefined value when provided
What is the current behavior?
Select displays nothing
What are the steps to reproduce?
http://plnkr.co/edit/i919jzNOoXhlPeN4hxxE?p=preview
What is the use-case or motivation for changing an existing behavior?
Adding a default option with text for a null value should result in displaying the text when the current model value is null.
For example, adding a default option with text “None”
<md-option>None<md-option>
should show “None” when the select list is closed.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular: 4.3.4 Material: Beta 8
Issue Analytics
- State:
- Created 6 years ago
- Reactions:11
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Angular Material: mat-select not selecting default
I am trying to set the value to default to one of the options, however it is being left selected when the page...
Read more >Angular Mat-Select Text: Customize the Appearance
Learning how to use Angular MatSelect using JavaScript. Learn how to format select options in this web dev tutorial.
Read more >Select | Angular Material
<mat-select> is a form control for selecting a value from a set of options, similar to the native <select> element. You can read...
Read more >Default "null" option not working in select constructed with v ...
I'm having trouble getting the default “null” to display when populating a select using v-for and an array of objects as the data...
Read more >Empty value "- Select -" does not appear for select fields with ...
However, when I create a second select box that depends on the first using #states , it does not have any such default...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Closing as working as intended. As noted above, this was a deliberate choice made in the
mat-select
If providing a
<md-option [value]="undefined">None</md-option>
or<md-option [value]="null">None</md-option>
then I would think the intent is clear, even for untouched selects. Without those options, it’s clear that there is no associated text and the select should display a blank.It just seems unexpected when
<md-option [value]="someValue">Text</md-option>
would display the text while<md-option [value]="null">None</md-option>
does not.