How to: Autocomplete search bar

I’m trying to obtain something like this:

I’m trying this plugin.
It works, but i need to receive more than only one field back (like description and image).


import {AutoCompleteService} from 'ionic2-auto-complete';
import { Http } from '@angular/http';
import {Injectable} from "@angular/core";
import 'rxjs/add/operator/map';

export class AutocompleteProvider implements AutoCompleteService {
   labelAttribute = "name";

   constructor(private http:Http) {}
   getResults(keyword:string) {
        return this.http.get(""+keyword)
	   result => {
	     return result.json()
	     .filter(item =>

<ion-auto-complete [dataProvider]="autocompleteProvider"></ion-auto-complete>


import { AutocompleteProvider } from '../../providers/autocomplete-provider';
    selector: 'page-root-spesa',
    templateUrl: 'root-spesa.html',
export class RootSpesa {
    constructor(public autocompleteProvider: AutocompleteProvider) {}

Is possible to retrive other field than the standard labelAttribute (according to the manual) in the html?

According to the manual of this plugin, it’s supports custom templates for the list items, but i got this error following the tutorial:

More than one component matched on this element. Make sure that only one component's selector can match a given element. Conflicting components: AutoCompleteItemComponent,CompTestIte

Here the plugin:

How to select only one component at a time?
The component in html must use the extended class, but currently uses both original and extended.


No one has implemented the autocomplete search?

Do you mean something like this? Sorry if I misunderstood your question.

its simple as this…
this.dataService = completerService.local(this.searchData, 'name', 'name').imageField("image").descriptionField("description");

1 Like

Seems good! I take a look now, thx you!

Hi!! Did you know how can i get the id from the selected item?

My directive:

<ion-auto-complete class="ion-autocomplete" name="id" max-selected-items="1" [(ngModel)]="" [dataProvider]="hotelservice" autocomplete="off" ng-model="model" item-value-key="id" items-clicked-method="clickedMethod(callback)" >

items-clicked-method doesnt work, can you help me please

I know this is too late but it may help some one…

I have created a repository take a look on it…

1 Like