Topic: Autocomplete reset/clear

Lumpenstein free asked 2 years ago


I got tasked migrating all of our applications from MDB4 to MDB5, but I am having trouble finding a solution to reset the options inside autocompleted inputs.

In MDB4 it was possible to clear it using the directive:

this.autocompleteDirective.clear();

but that doesn't seem to exist anymore and I wasn't able to find a workaround, is there a way ?

E.g. An autocomplete input with options ["1", "2", "3"], when I type 1 and select it, even after resetting the persisted/displayed value, the dropdown only shows ["1"] until I manually update the input.

BR, Lumpi


Arkadiusz Idzikowski staff answered 2 years ago


@Lumpenstein In MDB5 you just need to reset the value of the form control attached to the autocomplete input.

If you use ngModel: this.searchText.next('');

If you use formControl: this.control.setValue('');


Lumpenstein free commented 2 years ago

Thanks a lot that worked πŸ‘



Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Resolved

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: MDB5 2.1.0
  • Device: PC
  • Browser: Edge
  • OS: Windows
  • Provided sample code: No
  • Provided link: No