question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

md-select does not display default (null) option text in mat-select-value

See original GitHub issue

Bug, 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:closed
  • Created 6 years ago
  • Reactions:11
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

21reactions
josephperrottcommented, Sep 27, 2017

Closing as working as intended. As noted above, this was a deliberate choice made in the mat-select

18reactions
martin-the-geekcommented, Aug 17, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found