How to include values from an array in a checkbox inside an alert?

For example - I’ve an array like this:

public Market = [‘Apple’, ‘Vegatables’, ‘Orange’, ‘Banana’, ‘Pear’]

And this Alert:

async Alert1() {

const alert = await this.alert.create({

  cssClass: 'my-custom-class',

  header: 'Market',

  inputs: [

{

      name: 'checkbox1',

      type: 'checkbox',

      cssClass: 'secondary',

      label: {{Market [0]}} ,

      value: 'value1',

     

    },

    {

      name: 'checkbox2',

      type: 'checkbox',

      cssClass: 'secondary',

      label: {console.log (Market [3])},

      value: 'value1',
    }
  ]

I need to use the values ​​of my array in the checkbox label. I used some commands like: {{Market [0]}} and {console.log (Market [0])}; but none of them worked. How do I do that? After selecting an item from the selection box, how do I change the color of a button?

const alert = await this.alert.create({

  cssClass: 'my-custom-class',

  header: 'Market',

  inputs: [
{

      name: 'checkbox1',

      type: 'checkbox',

      cssClass: 'secondary',

      label: Market[0] , (or probably this.Market[0]) - pending where you declared Market

      value: 'value1',
     },

This is a short answer to one of your questions.

1 Like

thank you so much! Worked!

1 Like