mdb-auto-completer component displayValue - get selected val


Topic: mdb-auto-completer component displayValue - get selected value

Jared Bratu pro asked 5 years ago

I'm trying to use the displayValue input of the MdbAutoCompleterComponent by adding [displayValue]="onDisplayValue" to my template. The onDisplayValue function is triggering and I'm able to set a value, i.e.

onDisplayValue () { return 'some display value'; }

This will cause 'some display value' to appear in the field.

The problem is I can't determine what value was selected for the onDisplayValue function to alter it. The displayValue function seems to trigger before the data-bound element is set or the select/selected outputs are emitted.

How can I get the value of what was selected or entered in the mdb-auto-completer function using the displayValue input?


Jared Bratu pro answered 5 years ago

I found the answer. The displayValue function has one parameter which is the value selected. If I change my onDisplayValue function to:

onDisplayValue (v) { 
  return 'now displaying ' + v; 
}

Everything works as expected. The documentation about displayValue wasn't clear.


Bartosz Termena staff answered 5 years ago

Dear @Jared Bratu

Thank you for the response, we will take a closer look on our documentation, and we'll make the necessary corrections.

Best Regards, Bartosz.


FREE CONSULTATION

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

Status

Closed

Specification of the issue
  • User: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: 8.3.1
  • Device: Desktop
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No