Skip to content

md-select preselected value #2882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lynxone67 opened this issue Feb 1, 2017 · 6 comments
Closed

md-select preselected value #2882

lynxone67 opened this issue Feb 1, 2017 · 6 comments

Comments

@lynxone67
Copy link

I have following code:

<md-select placeholder="Country" (ngModel)]="person.address.country">
      <md-option *ngFor="let krajina of country | async" [value]="krajina.id">
             {{krajina.abbreviation_iso}}
      </md-option>
</md-select>

When my form loads it doesn't show the corresponding link of preselected value. I saw more issues with similar question, but none of them solved my problem. Can anyone help, please?

@web265p3
Copy link

web265p3 commented Feb 1, 2017

Yep! Same problem :)
But for me it almost works. If I preselect something programmatically nothing is preselected at first. But if I click the control, the selection "refreshes" and the right value is put into the field.

@fxck
Copy link
Contributor

fxck commented Feb 1, 2017

Provide a plunk reproduction. You are missing [ at ngModel, not sure if that's just a typo in this issue or it's your actual code. Try putting *ngIf="(country | async)?.length" on md-select, it could work as a workaround.

Slightly offtopic but..

let krajina of country

..makes me cringe.

@lynxone67
Copy link
Author

*ngIf="(country | async)?.length" did't work for me.

@web265p3
Copy link

web265p3 commented Feb 1, 2017

Opps - for me it was just the problem, that I used onPush. With default it works. So in my case it was just this issue :)

@crisbeto
Copy link
Member

crisbeto commented Feb 1, 2017

I'll close this as a duplicate. There's a pending fix for the OnPush issue.

@crisbeto crisbeto closed this as completed Feb 1, 2017
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants