1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How to enable/disable an Ionic >=2 alert button if there are no input selections

Discussão em 'Angular' iniciado por peterc, Julho 21, 2025.

  1. peterc

    peterc Guest

    I have an Ionic alert with radio button options, and would like to disable an OK button until the user has made a selection. Very similar to this post, except I want to do it on an action from the alert itself and be able to update the button "enabledness", so my setup would be like 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 would like the OK button to be initially disabled, but then enabled as soon as the user makes a selection. Since the ion-select also uses the alert, it would be good to be able to use the same thing there.

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

    Continue reading...

Compartilhe esta Página