oferh / ng2-completer

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

CompleterService - Templating searchFields and titleFields #214

Closed DarioN1 closed 7 years ago

DarioN1 commented 7 years ago

Hi, I'm trying to implement a completer using completerservice.

This is what I'm trying to do:

this.dataService = this.completerService.local(this.listCustomers,'code,businessName','businessName," -cod:",code');

The search works properly, I can search by code and businessName, but the title of the options is not showed properly...

I want so render something like this: "testcustomer - cod:1234" by combining code , some text and businessName but in this moment I get:

testcustomer undefined 1234

Ho can I template it ?

Thanks

oferh commented 7 years ago

@DarioN1 Hi, TitleField accepts only the names of the fields not a format so you should pass in "businessName, code"

if you want to format the output you can either:

  1. add a field that has the format you want to the input array
  2. create a custom CompleterData that will create the items with the title you want
DarioN1 commented 7 years ago

Thanks Oferh, I solved the problem by adding a new field to the input array.