md-select doesn't work for dynamic options
See original GitHub issueThe underlying framework supports this but ember-materialize doesn’t perform the required javascript call when the ‘content’ field on md-select changes.
Workaround: create an observer in your application that calls the necessary javascript function to rebuild the md-select’s ul/li list Eg.
_selectRefresher: Ember.observer('_fields', function () {
// ember-materialize does not perform the refresh needed by the Materialize CSS framework
Ember.run.next(() => {
Ember.$('select').material_select();
});
}),
{{md-select
content=_fields
value=_selectedFieldPriorityId
optionLabelPath="content.translation"
optionValuePath="content.key"}}
The fix for this issue is simple. Inside the md-select component this observer should exist so that the application using the addon doesn’t need to do it themselves. I’m under a deadline right now and don’t have time to create a PR but if someone doesn’t get around to this at some point I’ll hopefully have time to make the PR myself. Mainly added this so that people that are having the same problem will know the work around.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Angular Material md-select does not show selected Item (bind ...
I already tryed that. It did'nt work. And what's funny, when I put "{trackBy: '$value.id'}", it initiates selected the both items, but them...
Read more >Dynamic population of md-select not working #1334 - GitHub
I'm trying to create a component around md-select that dynamically creates the content list after the component is first instantiated.
Read more >Directives > mdSelect - AngularJS Material
Parameter Type Description
* ng‑model expression expression Assignable angular expression to data‑bind to.
placeholder string string Placeholder hint text.
Read more >Angular Material Mat Select Dynamic Data Binding ... - StackBlitz
Select with 2-way value binding. ... <mat-option *ngFor="let education of. educationList" [value]="education. educationLevelName" >{{ education.
Read more >Dynamically alter options in mdb-select
The above works fine in regular Angular, but when I convert to mdb-select using a dynamic collection, it doesn't update based on ngIf....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I ran into this problem as well.
Using the following works like a charm:
@DanLatimer is issue based on adding new options or modifying options? If the later could probably add dependent dynamic keys, explained here
@EWhite613 I found the same solution appropriately working.