Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,60 @@
# Ionic2-auto-complete

Bug #107 of tap event propogation Fixed

## Multiple Select ##
Can be used as multiselect in this way ->
In this example adduser is model for the Selected item in current Selection,removelist is array of all selected items to show as buttons to remove them from list and userlist is string of all selected items seperated by comma

``` <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>
```
On ts file (removelist is an array and selectedlist is string list of selected items seperated by a comma) ->
```
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(",");
}
}
```


## Disclaimer ##
Due to a very little free time, I am not fully available for mainting and supporting this project, so contributions are very welcome!!!

Expand Down
2 changes: 1 addition & 1 deletion src/autocomplete.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const defaultOpts = {
<span [innerHTML]='attrs.label | boldprefix:attrs.keyword'></span>
</ng-template>
<ul *ngIf="!disabled && suggestions.length > 0 && showList">
<li *ngFor="let suggestion of suggestions" (tap)="select(suggestion);$event.srcEvent.stopPropagation()">
<li *ngFor="let suggestion of suggestions" (click)="select(suggestion);$event.stopPropagation()">
<ng-template
[ngTemplateOutlet]="template || defaultTemplate"
[ngTemplateOutletContext]="
Expand Down