Components: md-select default value is not support object?

Created on 30 Aug 2017  路  5Comments  路  Source: angular/components

Bug, feature request, or proposal:

I want to display selected value in md-select, the value is an Object. not string.

What is the expected behavior?

to display the correct option from the select.

What is the current behavior?

not display.
in the plunker should be: "United States" at the begging.

What are the steps to reproduce?

here:
https://plnkr.co/edit/nCJLd5?p=preview

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

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

Is there anything else we should know?

Most helpful comment

You can now pass a compareWith function to MdSelect. See https://material.angular.io/components/select/api

All 5 comments

This is not a bug. Please keep GitHub issues for bug reports / feature requests. Better avenues for troubleshooting / questions are stack overflow, gitter, mailing list, etc.

As pointed out by @donroyco, this is not a bug. Even though the Object you passed to selectedCountry looks like countries[1], they are different objects so the select wouldn't know which option to display.

In order to select any of the options, you have to select one of the objects you passed to the select, i.e. an Object from the countries list. Here's an updated plunker: https://plnkr.co/edit/GmlISyGT3BSBWxAryEiD?p=preview

You can now pass a compareWith function to MdSelect. See https://material.angular.io/components/select/api

@willshowell YEAH!!! U R D BEST! :)

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._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michaelb-01 picture michaelb-01  路  3Comments

theunreal picture theunreal  路  3Comments

MurhafSousli picture MurhafSousli  路  3Comments

jelbourn picture jelbourn  路  3Comments

vanor89 picture vanor89  路  3Comments