user5260143
user5260143

Reputation: 1098

Ionic2, ion-select multiple - limit user selection

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?

Upvotes: 3

Views: 3562

Answers (2)

Thiago Nascimento
Thiago Nascimento

Reputation: 1

unfortunately he doesn't have that kind of support. An alternative would be to add the maxlength directive stating the number of selected items desired. Thus, if a larger value is selected, the field will be invalid in the form.

Upvotes: 0

amin arghavani
amin arghavani

Reputation: 1883

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
     }
}

Upvotes: 4

Related Questions