Ionic3 Action Sheet with Variable Inputs


#1

Hi,
I need to create an action sheet or some other kind of alert which displays options to a user and saves the option they clicked in a variable. However, the options are being retrieved from Firestore and whilst I’ve been able to display these options in an action sheet, I’m struggling to get the value of the option they clicked.

Below is my code for the function so far. The list of options is retrieved from Firestore and saved in an array called ‘options’.

  categorizeProblem(){
    this.action = this.actionCtrl.create({
      title: "What sort of problem did this student have?",
    })
    this.options.forEach(option => {
      var button = {
        text: option,
        value: //option name
        handler: (data)=> {
          //Need to get the value/name of the option clicked and save this in a variable
        }
      }
      this.action.addButton(button);
    })
    this.action.present();
  }

I would really appreciate it if someone could help me with this!