Skip to content
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

Md-Select start value or active value #1973

Closed
dahaupt opened this issue Nov 23, 2016 · 12 comments · Fixed by #2038
Closed

Md-Select start value or active value #1973

dahaupt opened this issue Nov 23, 2016 · 12 comments · Fixed by #2038
Assignees
Labels
P2 The issue is important to a large percentage of users, with a workaround

Comments

@dahaupt
Copy link

dahaupt commented Nov 23, 2016

Bug, feature request, or proposal:

Feature request

What is the expected behavior?

The Md-Select-Component should be able to have a start value, which should remain active even after the page has been reloaded.

After reloading or switching routes I wanna see it like this:
Image

What is the current behavior?

We can't set a start value for select. We can click a button to set it, but there is no attribute available to bind it directly with a variable.

What are the steps to reproduce?

Look into existing select examples and try to set a startup value.

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

Angular Material latest version (from master)

Is there anything else we should know?

I am not sure if I just don't see the way to do it or if it's already planned for the future.

@dahaupt dahaupt changed the title Md-Select default start value or active value Md-Select start value or active value Nov 23, 2016
@bastienlemaitre
Copy link

Hi, md-select has not been released yet.
Please see https://github.com/angular/material2/blob/master/README.md.

Will be released in alpha.11

@dahaupt
Copy link
Author

dahaupt commented Nov 24, 2016

@bastienlemaitre Hi, I am aware of that, but alpha.11 is already the next version and I can't find any plans (md-select in projects) to realize this feature.

@seanrkerr
Copy link

seanrkerr commented Nov 28, 2016

@kara & @jelbourn, Just a question around the release date of the Alpha 11. Will this be in November or are we looking at December for this one? Would like to use md-select but if I can't will write my own.

Thanks in advance.

@jelbourn
Copy link
Member

We don't yet have an exact date for the next release.

@seanrkerr
Copy link

ok, no worries.

@jelbourn
Copy link
Member

@dahaupt I don't quite follow- is this not just the value property of the select?

@kara
Copy link
Contributor

kara commented Nov 30, 2016

@dahaupt The select is a custom value accessor, so you should be able to use ngModel or any other available form directive in Angular 2.

<md-select [(ngModel)]="food"></md-select>

@dahaupt
Copy link
Author

dahaupt commented Nov 30, 2016

@kara & @jelbourn This would lead me to set the value with a FormControl object for example. Let's stay in the demo-app select example:

foodControl = new FormControl('pizza-1');

This should set a start value of the md-select component. But even if the value is right now, I can just see the placeholder:
wrong behaviour

This button works fine:

<button md-button (click)="foodControl.setValue('pizza-1')">SET VALUE</button>

How can I achieve that in the TypeScript of my component before? What am I doing wrong?

@jelbourn jelbourn added the P2 The issue is important to a large percentage of users, with a workaround label Nov 30, 2016
@kara
Copy link
Contributor

kara commented Nov 30, 2016

@dahaupt Aha! Okay, I see what you're talking about, thanks for clarifying. While setting the initial value using ngModel does work, setting an initial value using formControl doesn't yet because the value is written synchronously before the options exist. I'm submitting a quick fix that should make the code above work. When the select component is released, the fix should go out with it.

kara added a commit to kara/material2 that referenced this issue Nov 30, 2016
kara added a commit to kara/material2 that referenced this issue Nov 30, 2016
kara added a commit to kara/material2 that referenced this issue Nov 30, 2016
@dahaupt
Copy link
Author

dahaupt commented Dec 1, 2016

@kara Thanks and keep up the great work! 👍

@elvisbegovic
Copy link

elvisbegovic commented Dec 1, 2016

@kara can you please update plan for December ? These from november are OK?

Q: What's about 2 new employee (planned for October) ?

@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
P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants