mdb-select options with object


Topic: mdb-select options with object

chawinping asked a year ago

Hi

I read a doc of Angular Select and i see that the "optionsSelect" have to be Array of

{ value: '1', label: 'Option 1' }

but when i get data from my backend. it's in difference form like

[{ num: 1 , name: 'dog', color: 'red ' }, { num: 2 , name: 'cat', color: 'blue' } ]

so I have to loop and push my data to Array of { value: '1', label: 'dog' }.

Is there anyway to use my data without tranform to "{ value: '1', label: 'Option 1' }"? or anyway to use without loop thourght all of my object array?


Hope you understand my English.Thanks


cloed just know how to use map. my bad.


Status

Closed

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: Angular
  • MDB Version: 8.5.0
  • Device: PC
  • Browser: Chrome
  • OS: Win10
  • Provided sample code: No
  • Provided link: No