oferh / ng2-completer

Angular 2 autocomplete component
http://oferh.github.io/ng2-completer/
MIT License
347 stars 172 forks source link

Usage with Object results (Algolia) #242

Closed Bengejd closed 6 years ago

Bengejd commented 7 years ago

Great product, first off! It works out of the box, like nobody's business! One thing that I am having difficulty doing is populating the auto-complete results of the search with a series of Objects. When I query Algolia, I get the following: [Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object]

Do I have to create a custom CompleterData Object to achieve the auto-complete functionality with the data that I have?

Relevant API documentation:

oferh commented 7 years ago

@Bengejd thanks!

searchFields and titleField accept an object path notation, i.e. object.field that you can use.

Bengejd commented 7 years ago

Could you provide a little code snippet? I'm just having difficulty hooking up Algolia's API with the component to show the searched results. With Algolia, you search the index's like so: index.search(event.query, (err, content) => { console.log(content.hits); this.searchData = content.hits; // This is how I was populating the searchData results, but i'm // not sure if it's correct. });

oferh commented 7 years ago

not familiar with Algolia, can you create a plunk or add a sample of the data you get in content.hits?