Topic: Asynchronous Autocomplete with objects as result

itkaufmann priority asked 1 week ago

*Expected behavior*I want to build an autocomplete input that get asynchronous results from my backend. My results are of objects of the form {id: number, postalcity: string}. I now want the options to show the .postalcity attribute, and also want the input to show the postalcity value after selection of an option. All of that works as expected: -> options show the postalcity value and the input as well after one is selected (PERFECT SO FAR!)

enter image description here

However: I want my formcontrol to have the form {id: number, postalcity: string} as well, once an option is selected. But it is always just of the form of the postalcity string.

enter image description here

It only becomes an object if I change/remove the displayValue function, but then value inside the input field also becomes an object [Object, Object].

enter image description here

*Actual behavior*Is it possible to fix that? Can I only show a single object field to the user, while still setting the formcontrol to the whole object if one is selected? Thank you very much in advance!

Resources (screenshots, code snippets etc.)![enter image description here] enter image description here ( image description here

*NOTE*Loading the data asynchronously works fine! Selecting the options as well! it is JUST about the value that the formField gets set to. Thanks!

Arkadiusz Idzikowski staff commented 1 week ago

The component should always return mdb-option value to the form control. We are already aware of this bug and it will be fixed in the next update.

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • User: Priority
  • Premium support: Yes
  • Technology: MDB Angular
  • MDB Version: MDB5 3.0.0
  • Device: Lenovo T14
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: Yes