-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
mat-select not pre selecting a value when mat-option has async content #7923
Comments
+1 |
well #6970 (comment) this |
Hey @p0d3r, #6970 seems to be something else entirely. It describes a situation where the options are generated dynamically. The OP was surprised that the selected value was 'lost' when a new set op options was assigned. |
I'm having the exact same issue. |
I am also having the same issue with Reactive forms Module.. Does anybody found the solution? |
The issue here comes from the fact that the displayed value of the select comes directly from the |
so basically... its an non-standard select html element which has the material design but less features? I'll stick to the default aka. normal select element then. doesn't make any sense not being able to show the default/selected at init. |
It is possible to have a preselected value, it's currently not possible to have the label change asynchronously after init. |
Is it possible to trim the selected value? e.g., i'm choosing a country phone code and want to show the full country name in the menu but only the code after selected? have hunted through several threads with nothing definitive. thanks |
For now my workaround is like this
Bind in Template
|
Move language management into a dedicated language service Add component in header to select current language Use bootstrap select style and custom event management instead of mat-select because of angular/components#7923 issue and not trivial style configuration
A terrible hack to use with dynamically loaded options that may or may not contain the currently selected item, but you want to show the select item info in the select trigger, is to always have the selected item as an option that is hidden.
Or you could use |
Currently `mat-select` doesn't react to changes in the label of its options, which is problematic, because the option label might be populated at a later point by a pipe or it might have changed while the select is closed. These changes add a `Subject` to the `MatOption` that will emit whenever the label changes and allows the select to react accordingly. Fixes angular#7923.
Currently `mat-select` doesn't react to changes in the label of its options, which is problematic, because the option label might be populated at a later point by a pipe or it might have changed while the select is closed. These changes add a `Subject` to the `MatOption` that will emit whenever the label changes and allows the select to react accordingly. Fixes angular#7923.
Currently `mat-select` doesn't react to changes in the label of its options, which is problematic, because the option label might be populated at a later point by a pipe or it might have changed while the select is closed. These changes add a `Subject` to the `MatOption` that will emit whenever the label changes and allows the select to react accordingly. Fixes #7923.
Currently `mat-select` doesn't react to changes in the label of its options, which is problematic, because the option label might be populated at a later point by a pipe or it might have changed while the select is closed. These changes add a `Subject` to the `MatOption` that will emit whenever the label changes and allows the select to react accordingly. Fixes angular#7923.
Currently `mat-select` doesn't react to changes in the label of its options, which is problematic, because the option label might be populated at a later point by a pipe or it might have changed while the select is closed. These changes add a `Subject` to the `MatOption` that will emit whenever the label changes and allows the select to react accordingly. Fixes #7923.
Currently `mat-select` doesn't react to changes in the label of its options, which is problematic, because the option label might be populated at a later point by a pipe or it might have changed while the select is closed. These changes add a `Subject` to the `MatOption` that will emit whenever the label changes and allows the select to react accordingly. Fixes angular#7923.
Hi, this solution I found is to set a value when we're going to initialize the view and also initializing our ReactiveForm, then when we retrieve the list of options with an Async call we reset the value in the "complete" callback:
2.RESET:
Hope this will Help |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug, feature request, or proposal:
Bug
What is the expected behavior?
When the ngModel of a mat-select is populated on page load the mat-select should have that option selected.
What is the current behavior?
mat-select does not show the current selected option on page load if a mat-option has some async behaviour, in my case the translate pipe:
The current selected option is shown the moment the mat-select gets focus.
What are the steps to reproduce?
Please have a look at the following StackBlitz example:
https://stackblitz.com/edit/angular-material2-issue-async-mat-option-label?file=app%2Fpet-select-async%2Fpet-select-async.component.ts
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
material beta 12
angular 4.4.3
The text was updated successfully, but these errors were encountered: