How to get User input from action sheet in ionic


I new to ionic I was wondering how can I take the user input from the alert so I can store it for pass it to another function?

let prompt = this.alertCtrl.create({
          title: 'code',
          message: message,
          inputs: [{
              name: 'Code',
              placeholder: 'code',
          buttons: [{
               text: 'Cancel',
               handler: data => {
               console.log('Cancel clicked');
           text: 'ok',
           handler: data => {


I know the question is a bit old but I would like to answer it.

The magic object You are looking for is the data object in the handler function, which should be binded to each button.

If You console.log(data); inside the handler You’ll get a object, in Your case it would be { Code: 'the users input'}.

Have a look presentPrompt() function at the docs: