MDB autocompleter - capturing selected value


Topic: MDB autocompleter - capturing selected value

getitdonefitness asked 6 years ago

The documentation does not specify how to capture selected value form autocompleter component. I tried to use (select) method but that was not helpful. How do I pass the selected option to my component from the template?

<div class="md-form"> <input type="text" class="completer-input form-control mdb-autocomplete" [(ngModel)]="searchText" (input)="getFilteredData()" (ngModelChange)="onChange()" [mdbAutoCompleter]="auto" placeholder="Choose your client"> <mdb-auto-completer #auto="mdbAutoCompleter" (select)="onSelect($event)" textNoResults=""> <mdb-option *ngFor="let option of results " [value]="option.lastName"> {{option.lastName}} - {{option.email}} </mdb-option> </mdb-auto-completer> </div>


Arkadiusz Idzikowski staff answered 6 years ago

Please take a look at our example with preselected value. The value you select will be stored in the 'testAutocomplete' form control.

https://mdbootstrap.com/docs/angular/forms/autocomplete/#preselect-reactive


Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: 7.4.3
  • Device: laptop
  • Browser: chrome
  • OS: mac
  • Provided sample code: No
  • Provided link: No