Ionic: Showing an alert controller with a checkbox and text input

Viewed 7979

I am trying to show a checkbox along with a text input field. (Ionic 3.5.3)

The checkbox is not showing up. I looked at another SO thread for a similar question. The code seems to be the same as what I am doing.

The code:

let alert = this.alert.create({
      title: 'Name your trip',
      inputs: [
      {
        name: 'name',
        placeholder: 'Your trip name',
      },
      {
         name: 'gpsxy',
         type:'checkbox',
         checked:true,
         label:'Log GPS co-ords',
         value:"true"
      }
    ],

      buttons: [{
        text: 'Cancel',
        role: 'cancel',
        handler: data => {
        }
      },
      {
        text: 'Ok',
        handler: data => {
      }],
    });
    alert.present();

And here is the screenshot:enter image description here

2 Answers

Definitely the right thing to do is to create a modal. But I use a workaround, by nesting alerts. I explained and have a working demo in my answer here

Related