<md-select placeholder="Profile" [formControl]="profilesFormControl">
<md-option *ngFor="let profile of profiles" [value]="profile">
{{ profile.Name }}
</md-option>
</md-select>
Following normal select box populates fine:
<select >
<option [ngValue]="profile" *ngFor="let profile of profiles">
{{ profile.Name }}
</option>
</select>
Bug
Successfully populate md-select control
md-select control does not populate whereas If I use normal
Angular: 4.2.5
Material: 2.0.0-beta.8
OS: Windows 10 x64
Typescript: 2.3
Please, provide a plunk to help your issue to be better understood: http://plnkr.co/edit/o077B6uEiiIgkC0S06dd?p=preview
Yeah, we'll need a more complete example to help debug. Can you provide a plunker link?
I am really sorry but I have huge codebase and cannot extract the code that load this. It is fetching data from server using websockets. Nothing special about it. As I wrote above the normal select element works just perfect.
@pantonis a lot of similar issues have come up due to md-select currently comparing objects by reference (https://github.com/angular/material2/issues/2785). You may be seeing a symptom of that.
Here's an example of it working with reactive forms https://plnkr.co/edit/ix90KHY8HAInJ5fWxtpJ?p=preview
@pantonis We'd love to help with the issue but we are having trouble reproducing the bug. Feel free to reopen with a plunker example so we can investigate and fix the problem.
Ran into the same issue.
@andrewseguin I've created a minimal example here: https://stackblitz.com/edit/angular-material2-md-select-issue to help you investigate. [EDIT]: Updated StackBlitz URL.
There are two md-select components in that example, one (country1) uses an initial value from the array of options (countries), while the other (country2) uses an initial value that looks the same but is a different object. Might be related to #2785 as @willshowell pointed out.
This might help you investigate. Thanks for all the great work on this project 馃憤
@pastafari I think you forgot to fork the stackblitz :D Also, select now was a compareWith input to combat this exact problem! You can compare your countries by some other unique property besides Object reference.
@rafaelss95 also has an example of compareWith here :https://github.com/angular/material2/issues/6970#issuecomment-328355857
@willshowell yes I did notice compareWith, however that will require an update to beta-12, which means I need to /s/md/mat, which I don't have time for just yet :)
@pastafari you're in luck, it was added in beta.10. Also the prefix updater tool is very easy and, for us, a regex followup took only a couple minutes.
has this issue been closed? I can't populate 'mat-select' by using reactive forms. Should I open a ticket with an example?
running same issue when I'm using production. while my development shows no error.
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._
Most helpful comment
has this issue been closed? I can't populate 'mat-select' by using reactive forms. Should I open a ticket with an example?