components icon indicating copy to clipboard operation
components copied to clipboard

Initialized value of md-select is not displayed

Open danny-swimmer opened this issue 9 years ago • 2 comments

Bug, feature request, or proposal:

Bug

What is the expected behavior?

When the value of md-select is set in the constructor, the initialized value should be displayed in the pulldown list.

What is the current behavior?

The initialized value is not displayed in the pulldown list.

What are the steps to reproduce?

Please refer to this plunk: https://plnkr.co/edit/sxC4c3CgKmmARF6Jq9XA In this example, the selectedValue is initialized to 3 (Steak), but "Steak" is initially not shown in the pulldown. Only after the user explicitly selects "Steak" is it shown.

What is the use-case or motivation for changing an existing behavior?

It should be possible to display an initial value for md-select.

Which versions of Angular, Material, OS, browsers are affected?

Angular: 2.4.8 Material: 2.0.0-beta.2

Is there anything else we should know?

No.

danny-swimmer avatar Feb 22 '17 18:02 danny-swimmer

If you want an option to be selected, its value has to equal the value of the ngModel. In your example, your option value is "3" while ngModel value is 3. Binding to the value property should conserve the type. See updated plunker here.

kara avatar Feb 22 '17 21:02 kara

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.