Closed KevinBeckers closed 1 month ago
this.customer
is an object which has [object Object]
as the string representation.
When autocomplete, it sets toString()
to display properly.
Thus, please set toString()
to display it properly.
This is an example.
ngOnInit() {
this._invoiceService.getInvoice(this.invoice.id).subscribe(result => {
this.customer = result.customer;
this.customer.toString = () => this.customer.name;
});
}
Hi @allenhwkim, Good day to you. want to create a new pull request to solve the mentioned issue. it can be solved adding the following condition in the ngOnInit function and it resolves an issue that a form control value converted from object to string for a selected value. please review below plunker to reproduce the issue Plunker
else if (!!this.formControl && this.formControl.value) {
if(this.displayPropertyName)
this.selectNewValue(this.formControl.value[this.displayPropertyName]);
else
this.selectNewValue(this.formControl.value);
}
@itsashish-patel you may add pull request I think, thanks.
This issue is stale. Please consider opening a new issue with details for the latest version if you are still facing the same issue or need improvement.
Closing it.
I have te following input. I would like to fill the input on init. But when I do the input will display [object Object] instead of
customer.name
. When autocomplete the customer name is displayed properly. So the problem only occurs with the init method.