right now the Angular2 AutoComplete compontent only supports string values, which is not sufficent in a scenario, where you want to find for example a customer based on his name. There could be multiple entities with the same name, but I also do not want to display the database id to the user. So what to do?
I hope, that this will get implemented in the AutoComplete Component soon, but for now this is my workaround I would like to share:
1. You have to modify the autocomplete.component.js so it will accept complex objects without throwing an exception.
Remove the if statement from lines 315-317:
Remove the first "toLowerCase()" call from line 426, so it should look like this:
And that is it. You can now pass an Array of customers to as [data]
However there are some things you have to be aware of:
When you select a value from the AutoComplete there will be two consecutive value changes. First will be your complex object, the second will be the string representation (customer.toString()). So I recommend, that you use a setter on your ngModel:
You also should write a toString() on your model, that you can display to the user.
I hope this helps some people and maybe serves as a suggestion for the Telerik guys.