Topic: How Do I Populate mdb-select Dynamically

The Orange Dev House pro asked 6 years ago


I am trying to populate mdb-select with data from NgRx state. I have selected data that returns an observable of an entity, say data.titles. data.titles is an array of string. How do I get this to populate the mdb-select.

I am trying to avoid having to loop through my data list to transform it to value/label objects. Can I bind directly to mdb-select directly?


Arkadiusz Idzikowski staff answered 6 years ago


Hello,

Unfortunately, currently the only option to add data is to use [options] input and pass object with values and labels. 

Regards,

Arek


ak.leimrey pro commented 6 years ago

I'll be frank, I USED to dislike this bit but then I realized there is no feasible way to simply accept any object, but due to my inexperience. I don't feel like you guys have to change anything about it. I write an interface to comply with the form of a select box. If I require any other attributes from a select box I filter the corresponding value out of my original object. And from my own experience with other UI Frameworks... they basically do it the same way and/or require the user to use the ngForEach directive for the rendering. 


fodxp free commented 6 years ago

you can try something similar to this..

https://medium.com/@vladguleaev/reusable-angular-create-multiple-checkbox-group-component-84f0e4727677



Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Opened

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: 6.2.1
  • Device: Laptop
  • Browser: Chrome
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No