MikeH premium asked 5 years ago


Hi there I've added a select box into my angular application. When loading the page, the placeholders are shown correctly. But when I want to reset the Search-Criterias by setting the selected value to "0", the placeholders are no longer displayed.  (0 is a non-existing value in the select-options) How can i reset the selectbox so that the placeholder is displayed again?
<mdb-select[options]="eventDropDown"placeholder="Events"[(ngModel)]="searchEventId"name="eventId"></mdb-select>

Arkadiusz Idzikowski staff answered 3 years ago


@pparesh

If you use an older version of the component (mdb-select):

  1. Use template reference variable #select on the <mdb-select> element:

  2. Use ViewChild to get access to the select element in the Typescript file:

    @ViewChild('select') select: SelectComponent

  3. Use select clear() method to clear the selections:

    clearSelection() { this.select.clear(); }

This public method is currently not available in the new version (mdb-select-2), but this problem should be fixed in the near future.


pparesh priority answered 3 years ago


How to clear selected option from TypeScript file?


Arkadiusz Idzikowski staff answered 5 years ago


Dear MikeH, You can use [allowClear]="true" input to add reset button that will appear on the right side of the select input when you choose an option. Regards, Arek

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

  • ForumUser: Premium
  • Premium support: Yes
  • Technology: MDB Angular
  • MDB Version: 6.2.3
  • Device: PC
  • Browser: Chrome
  • OS: Windows
  • Provided sample code: Yes
  • Provided link: No