I have an ion-select that the selected value is coming from a sqlite database, meaning the value for [(ngModel)] is being populated async. In ionic v3 this would still work and would select the correct ion-option, with v4 it doesn’t. Is there any way to get this to work?
I just double checked and it has nothing to do with async data load or not. Even when I used a hard coded variable it still didn’t show the selected value until I clicked on the select, that’s when the selected value is automatically selected.
As a workaround I put the value in the ion-select placeholder attribute. That worked but it feels like a hack
1 more thing that I noticed, putting it here if anyone runs into this issue.
When it’s a multiselect (multiple=true) and you set [selectedText]=“selectedCodeValue” it will display 1 long string instead of comma separated string. The way I avoid it is as follows
hey @javasol thanks for posting your solution. this works for showing the string but when I open the action sheet it actually doesn’t show the selected values as selected (I’m having a multiselect option and I expect to see that when I open it the fetched values are already selected)
PS: this used to work when I could use the select property of the IonSelectOption but in Ionic 5 they removed support for that property)
I am working with Ionic Vue but I think I have a similar problem.
is your selectedCodeValue an Object of the selected element(s) or a string of the selectedText or both? somehow I still have problems setting the value and I don’t understand how your model and selectedText can be the same. and I have the same problem as @sabahang
thank you @twestrick for trying to help. yes in fact I am using v-model. the ion-select-options are all listed correctly and I can select them but I can’t get an initial value (a first pre selection) inside the ion-select. any trial with :value, :selected-text or other didn’t work