Topic: mdb-select how to pre-select options

marketingtech priority asked 2 years ago


Expected behavior mdb-select preselect options from oninit or constructor

Actual behavior no idea how can be achieved. I checked the source code but I couldn't find any property to send it.

Resources (screenshots, code snippets etc.)


Arkadiusz Idzikowski staff answered 2 years ago


Please take a look at this section in the documentation, we explained how to set a default value in template-driven and reactive forms:

https://mdbootstrap.com/docs/angular/forms/select/#section-set-value

You can also use [value] input if you don't need Angular forms: <mdb-select [value]="selectedValue">

It works the same in a multi-select but in this case, you need to define array of values (instead of string), for example: selectedValues = ['1', '2']



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: Priority
  • Premium support: Yes
  • Technology: MDB Angular
  • MDB Version: MDB5 2.3.0
  • Device: PC
  • Browser: Chrome
  • OS: Windows 11
  • Provided sample code: No
  • Provided link: No