How do I populate this checkbox with the data from an array in my controller?
My-view.js
My array in controller
arr = ["option 1", "option 2", "option 3", "option 4", "option 5"]
How do I populate this checkbox with the data from an array in my controller?
My-view.js
My array in controller
arr = ["option 1", "option 2", "option 3", "option 4", "option 5"]
I can't copy your code, since you posted it as a Image
, but this is how you can do it:
arr = ["option 1", "option 2", "option 3", "option 4", "option 5"]
let arrayResult = arr.map((option, optionID) => {
return {
"text": {
"type": "mrkdwn",
"text": option
},
"description": {
"type": "mrkdwn",
"text": optionID
},
"value": `value-${optionID}`
}
})
console.log(arrayResult)
Using arr.map()
will solve your problem.