Ionic 4 Ion-select-option not showing multiple selection


#1

ion-select-option is not showing prefilled multiple selected values.

I am trying to set some multiple values for ion-select but it’s not showing by default
if i hit ion-select it shows that values checked and also able to see its description text on lable
but before that it’s not come up.

Anyone has idea why this is happening?

Thanks


#2

Hello,

I’m having exactly the same issue than @manojpatel0217 when using ion-select in @ionic/core version 4.1.1 (web components on vanilla javascript, no Angular interface.)

I have something like this:

<ion-select multiple="true" value="1000,1001" >
    <ion-select-option value="1000">
        Geralt of Rivia
    </ion-select-option>
    <ion-select-option value="1001">
        Yennefer of Vengerberg
    </ion-select-option>
</ion-select>

You see that I set a list of values (comma separated, as it’s normally handled by the component, apparently), but none of the them is selected until the user clicks in the ion-select by herself and selects them.

On the other hand, if only one value is passed it’s handled correctly and the value appears as selected.

I think it’s a bug (I tried every way possible to initialize value, to no avail), and the documentation doesn’t help much.

Anyone else having the same issue? Is there something we’re doing wrong?

Thanks,


#3

Reported it as a bug, here:

https://github.com/ionic-team/ionic/issues/17785


#4

It’s not a bug. The value has to be an array of strings, and it has to be assigned from the code (not in the HTML template) to the property value in the ion-select element directly.

Reply here: https://github.com/ionic-team/ionic/issues/17785#issuecomment-472945471

Plunker with working code: https://plnkr.co/edit/K9l3rrZEroXkxg8uiV7N?p=preview