Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 230878

Ionic 4 ion-select pre select value

$
0
0

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

<ion-select [(ngModel)]="selectedCodeValue" name="selectCode" multiple="false" [placeholder]="selectedCodeValue ? selectedCodeValue : 'Tap to select..'"
        (ionChange)="codeSelected()" required >
        <ion-select-option *ngFor="let code of availableCodes" value="{{code.id}}">
          {{code.id}} -  {{code.description}}
        </ion-select-option>
  </ion-select>

Viewing all articles
Browse latest Browse all 230878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>