oferh / ng2-completer

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

RemoteData.dataField is not working for complex json data structure #362

Open ccteamworks opened 6 years ago

ccteamworks commented 6 years ago

Hi, Thanks for the great component. However it is not working for me in case of remote data which has bit complex data path. No completer list displayed and no error message what so ever.

dataService: RemoteData;

in constructor

this.dataService = CompleterService.remote(url, "_source.id", "_source.name"); this.dataService.dataField("suggest['user-suggest'][0].options");

Here is my response from remote server looks like {
"took":1, "suggest":{
"user-suggest":[
{
"options":[
{"_source":{ "name":"aaa","id":"aaa"}}, {"_source":{ "name":"bbb","id":"bbb"}}, {"_source":{ "name":"ccc","id":"ccc"}}, {"_source":{ "name":"ddd","id":"ddd"}} ] } ] } }

chenkins commented 6 years ago

@ccteamworks https://github.com/oferh/ng2-completer/blob/v2.0.0/demo/custom-data.ts