8000 md-select option not selecting with objects. · Issue #2250 · angular/components · GitHub
[go: up one dir, main page]

Skip to content
md-select option not selecting with objects. #2250
@jt-helsinki

Description

@jt-helsinki

Bug, feature request, or proposal:

Feature request/ bug.

What is the expected behavior?

Needs a "selected" attribute so the developer can specify the "selected" rule/logic.

What is the current behavior?

Option not being selected although the underlying model is populated.

What are the steps to reproduce?

Unable to select options using objects where some properties of the two objects differ yet primary key and Display value are the same. For example,

<md-option *ngFor="let user of Users" [value]="user">
    {{ user.name }}
</md-option>

The user may have one set of data inside the model yet only retrieve a subset of the properties to populate the 5DE9 select list. In this case, the options of the select do not select.

For such cases, it may be better to do something like:

<md-option *ngFor="let user of Users" [value]="user" [selected]="user.id === userId">
    {{ user.name }}
</md-option>

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

Using forms where objects are part of the underlying model. These objects are used as values of each .

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

Angular 2 latest.

Is there anything else we should know?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0