Unable to Bind the value from the service in the autoComplete feature
#### Bug, feature request
Hi Team,
I am using AutoComplete feature with Material2(Beta 3) + Angular 4 Versions. Now i am unable to bind the value of field from service in autoComplete.
#### What is the expected behavior?
It should bind two values in the autoComplete box. I can see the values in the drop down of autoComplete but the default value is showing as [object object].
Below is my code
> <md-input-container class="ABC">
<input mdInput [mdAutocomplete]="auto">
</md-input-container>
<md-autocomplete #auto="mdAutocomplete" class="addautoComplete">
<md-option *ngFor="let roles of xyz" [value]="roles">
{{roles?.field1}}{{roles?.field2}}
</md-option>
> </md-autocomplete>
Here xyz is the value of Objects return from service.
Any idea on this please?
Not able to bind two values in the autoComplete value field . Any idea please?
<input mdInput [mdAutocomplete]="auto">
</md-input-container>
<md-autocomplete #auto="mdAutocomplete" class="addautoComplete">
<md-option *ngFor="let roles of xyz" [value]="roles.field1">
{{roles?.field1}}{{roles?.field2}}
</md-option>
Have you tried the displayWith option? You add a function in your controller like this:
displayRoles(roles) {
if (roles != null) return roles.field1;
else return "";
}
Then add [displayWith]="displayRoles" to your md-autocomplete tag.
I tried the option earlier but i did the typo earlier when accessing the field. But it is resolved now. Thank you Jon
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.