2017-06-12 46 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()