Topic: mdb-auto-completer with option: { value, label } how to display the label
metalor-it
pro asked 2 months ago
Expected behavior Hello, I would like to display the option.label on in the mdb-auto-completer. - In html the convention for options are of { value, label } types. - In database I have { id: number, label: text } I expect the value to be set, and the corresponding label displayed
Actual behavior mdb-auto-completer set the 'value' correctly, but never display the 'label' as selected ! I see only the 'value' displayed
Resources (screenshots, code snippets etc.)
Answered
- User: Pro
- Premium support: No
- Technology: Angular
- MDB Version: 10.0.1
- Device: PC
- Browser: Chrome
- OS: Windows
- Provided sample code: No
- Provided link: No
metalor-it pro commented 2 months ago
The problem could be solved in the [displayValue]="onDisplayValue()" could pass the MdbOptionComponent object insted of only the value. Or is there any other way ?
Please advice. Thank you
Arkadiusz Idzikowski staff commented 2 months ago
Did you try to use code from this example? https://mdbootstrap.com/docs/angular/forms/autocomplete/#display-value
It uses the whole option object as a value but displays only the option name in the dropdown.