Open GCoe opened 6 years ago
I had the same issue and here's what I did. I used the inbuilt itemSelected event
<ion-auto-complete [dataProvider]="completeTestService" [template]="withFlags" #searchbar (itemSelected)="selectedItem($event)"></ion-auto-complete>
Then in my controller. I have the function
selectedItem(value) { console.log(value) }
It gets the selected item object
Thank you @yusufabayomio .
I'll try it. Ar'you using ionic2-autocomplete on a production environment ?
No. Its still on dev
Hi, I'm trying get the currently select object with this.searchbar.getSelection() .
The HTML :
<ion-col col-3> <ion-auto-complete #searchbar (autoBlur)="ProcessBlur()" (itemSelected)="ProcessItemSelected()" [dataProvider]="completeTestService" [(ngModel)]="myModelObject.name" [options]="{ placeholder : 'Select country' ,type : 'text'}"></ion-auto-complete> </ion-col>
The TS code :` ProcessItemSelected(){ console.log("Selected country -> ", this.searchbar.getSelection()) } ProcessBlur(){ console.log("Selected country on blur -> ", this.searchbar.getSelection()) }
When a new selection is done, the property myModelObject.numericCode is updated but the result from ProcessItemSelected() and ProcessBlur is always the object select before the click, not the current select object`