2017-06-12 47 views
0

我正在使用ionic3并希望添加一个“不要再问我”复选框以提醒。正如你可以看到下面我警报有三种选择:离子3 - 如何添加'不再问我'复选框到警报控制器?

1.save并继续

2.continue不保存

3.cancel

当用户点击该复选框仅选项“保存并继续“应该被启用,其余的被禁用。

Here is an example image.

的事情是我无法找到一个方法来捕捉复选框点击事件,为了做到这一点。 任何想法? 我使用警报控制器构建警报,而不是html。

+0

“当用户点击复选框只有一个选项应该被启用,其余禁用” ......什么选择?警报中的选项,表单中的选项?很难理解这个问题 – 2017-06-12 18:24:52

+0

我编辑了这个问题。希望现在更清楚。 – neomib

回答

0

报警控制器有一个名为inputs一个选项:

this 
    .alert 
    .create({ 
    title: 'Warning', 
    inputs: [ 
     { 
     type: 'checkbox', 
     label: 'don't ask me again', 
     handler:(e)=>{ 
      // e.checked is the checkbox value (true or false) 
      console.info('value: ',e.checked) 
     } 
     } 
    ], 
    buttons: [ 
     { 
     text: 'save and continue', 
     handler:() => { 
      //Do save stuff 
     } 
     }, 
     { 
     text: 'continue without saving', 
     handler:() => { 
      //Do continue without saving stuff 
     } 
     },{text:'cancel'} 
    ] 
    }).present()