ionic2-autocomplete icon indicating copy to clipboard operation
ionic2-autocomplete copied to clipboard

Multiple select?

Open pavel-kalmykov opened this issue 7 years ago • 3 comments

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?

pavel-kalmykov avatar Aug 25 '17 08:08 pavel-kalmykov

Unfortunately not in the near future :(

kadoshms avatar Aug 25 '17 12:08 kadoshms

any update on this? really useful feature.

sivajik34 avatar Mar 27 '18 10:03 sivajik34

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

vkbrulex avatar Apr 16 '18 04:04 vkbrulex