Ion-select close by choose value without click “Ok”


#1

Hi all ! Could anyone suggest please is it possible ion-select close by choose value without click “Ok” ?

 <ion-select [(ngModel)]="selectedType" (ionChange)="changePriceType()" *ngIf="shoppingCart>0">
     <ion-option *ngFor="let item of shoppingCart; let i =index" value="{{i}}">
        {{item.priceCaption}}
      </ion-option>
 </ion-select>

#2

Hi @anton_klochko,

You can use below mentioned code for avoiding OK button and directly clicking on the option value

 <ion-select [(ngModel)]="selectedType" interface="popover" (ionChange)="changePriceType()" *ngIf="shoppingCart>0">
     <ion-option *ngFor="let item of shoppingCart; let i =index" value="{{i}}">
        {{item.priceCaption}}
      </ion-option>
 </ion-select>

New thing is interface property of ion-select tag.

Hope this will resolve your issue.


#3

addwebsolution, it is working … thanks !


#4

i suggest using action-sheet. these two words remove ok button and when user click on a choice auto close the pop-up.

 <ion-item>
    <ion-label>Gender</ion-label>
    <ion-select interface="action-sheet">
      <ion-option value="f" selected="true">Female</ion-option>
      <ion-option value="m">Male</ion-option>
    </ion-select>
  </ion-item>

source :https://stackoverflow.com/a/39015858/308578