0

How do I populate this checkbox with the data from an array in my controller?

My-view.js

enter image description here

My array in controller

arr = ["option 1", "option 2", "option 3", "option 4", "option 5"]

Checkbox options should be option 1, option 2, [...] enter image description here

1 Answers1

0

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.