[Fixed] Ionic2, ion-select multiple – limit user selection

Issue

I’m new at Ionic2 and angular2.

I use ion-select plugin, and use multiple option.
Is there any way to limit user selection, for example till three items?

Solution

you can use ionChange event
in tempate:

<ion-select multiple="true" [(ngModel)]="selected_values"  (ionChange)="onSelect()">
                        </ion-select>

in ts:

selected_values=[];
onSelect(){
    if(this.selected_values.length==3){
        //do somthing
     }
}

Leave a Reply

(*) Required, Your email will not be published