How to put a checkbox input inside an alert prompt in Ionic2?

烂漫一生 提交于 2020-01-15 08:41:11

问题


Using Ionic2 and Angular2, I want to show an alert box, inside which a text along with checkbox - to ask for user if he/she agree to the statement.


回答1:


//Prompt an alert, to ask user to verify there email address.
let alert = Alert.create({
  subTitle: 'Email not verified!',
  message:  'Please check your email for verification link.',
  inputs: [
    {
      name: 'getLink',
      label: 'Get verification link again ?',
      type: "checkbox",
      value: "true",
      checked: false
    }
  ],
  buttons: [
    {
      text: 'Ok',
      handler: data => {
        console.log(data);
        if(data.length > 0) {
          //console.log('Get me link');
          //we are calling this method to sent a link to user over mail - to verify their email address.
          user.sendEmailVerification(); 
          this.nav.rootNav.setRoot(HomePage);
          return true;
        } else {
          //console.log('Link not required!');
          this.nav.rootNav.setRoot(HomePage);
          return true;
        }
      }
    }
  ]
});
this.nav.present(alert);


来源:https://stackoverflow.com/questions/38569163/how-to-put-a-checkbox-input-inside-an-alert-prompt-in-ionic2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!