ionic2-autocomplete
ionic2-autocomplete copied to clipboard
Multiple select?
There is an ionicv1 component here: https://github.com/guylabs/ion-autocomplete which offers to select multiple values.
Are you planning to implement something like this?
Unfortunately not in the near future :(
any update on this? really useful feature.
I have implemented a workaround solution for it . Append list of selected items to a array on selection display list on html page as button items on click of whose those elements are removed from array as well as html button is removed html code -
<div class="rm" *ngFor="let item of removelist; let i = index" style="float:left;">
<button (click)="RemoveItem(i)" style="float:left;"> {{item }} (x)</button>
</div>
<ion-auto-complete name="adduser" (itemSelected)="GetValue($event)" [(ngModel)]="adduser" [dataProvider]="UsersearchProvider" [options]="{ placeholder : 'Search Select And Add Username' }" ##searchbar ></ion-auto-complete>
ts code -
GetValue(ev: any)
{
if(this.selectedlist.includes(this.adduser)===false)
{
if(this.selectedlist==='')
{
this.selectedlist=this.adduser;
}
else
{
this.selectedlist=this.selectedlist+","+this.adduser;
}
this.removelist = this.selectedlist.split(",");
}
this.adduser="";
}
RemoveItem(i)
{
var item= this.removelist[i];
if(this.selectedlist.includes(","+item)===true)
{
this.selectedlist = this.selectedlist.replace(","+item,"");
}
else if(this.removelist.length===1)
{
this.selectedlist = this.selectedlist.replace(item,"");
}
else
{
this.selectedlist = this.selectedlist.replace(item+",","");
}
this.removelist = [];
if(this.selectedlist!='')
{
this.removelist = this.selectedlist.split(",");
}
}
declare selectedlist as blank string by default and removelist as an array