How to enable / disable Ionic alert button> = 2 if no input selection

I have a beep with radio button options and want to disable the OK button until the user makes a selection. Very similar to this post , except that I want to do this above the action from the alert itself and be able to update the "enable" button, so my setup will be similar to the following

  import { AlertController } from 'ionic-angular';

    export class MessageService {
      constructor(private alertCtrl: AlertController) {
      }

      presentAlert() {
        let alert = this.alertCtrl.create();

        alert.addInput({
          type: 'radio',
          label: 'Option 1',
          value: 'value1',
          checked : false
        });

        alert.addInput({
          type: 'radio',
          label: 'Option 2',
          value: 'value2',
          checked : false
        });

        alert.addButton('Cancel');
        alert.addButton({
          text: 'Ok',

          handler: data => {

          }
        });
        alert.present();
      }
    }

      

I want the ok button to be initially disabled, but then enabled as soon as the user makes a selection. Since ionic pick also uses alert, it would be nice to have the same thing in there.

Is this possible / is there an easy way to do this?

Thanks in advance for your help.

+3


source to share


1 answer


I may have been late, but it worked for me.

var bool=true;

      

and then in addInput



disable:bool

      

I'm not sure why I had to do this, but it works.

0


source







All Articles