Reputation: 1098
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
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
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