Ionic 2 Add radio buttons to alert controller

10,753

Try this.

advanceSearch(): void
{
    let prompt = this.alertCtrl.create({
    title: 'something',
    message: 'Select option ',
    inputs : [
    {
        type:'radio',
        label:'something1',
        value:'something1'
    },
    {
        type:'radio',
        label:'something2',
        value:'something2'
    }],
    buttons : [
    {
        text: "Cancel",
        handler: data => {
        console.log("cancel clicked");
        }
    },
    {
        text: "Search",
        handler: data => {
        console.log("search clicked");
        }
    }]});
    prompt.present();
}
Share:
10,753

Related videos on Youtube

Pasindu Nirmal
Author by

Pasindu Nirmal

Updated on July 16, 2022

Comments

  • Pasindu Nirmal
    Pasindu Nirmal almost 2 years

    How to add radio buttons as inputs buttons in an alert controller in ionic 2? It works with check boxes, but i want to add radio button group with radio buttons to select only one option.

      advanceSearch(): void{
       let prompt = this.alertCtrl.create({
        title: 'something',
        message: 'Select option ',
        inputs : [
         {
           type:'checkbox',
           label:'something1'
         },
         {
           type:'checkbox',
           label:'something2'
          }
    
        ],
        buttons : [
         {
           text: "Cancel",
           handler: data => {
             console.log("cancel clicked");
           }
         },
         {
           text: "Search",
           handler: data => {
             console.log("search clicked");
           }
         }
        ]
        });
        prompt.present();
    }
    

    `

    I want to change these check boxes to radio boxes.

  • Pasindu Nirmal
    Pasindu Nirmal almost 7 years
    Thank You @Dinuka
  • Yokesh Varadhan
    Yokesh Varadhan over 6 years
    is it possible to set Boolean to value of a button