如果密码不匹配,则离线警报显示错误

时间:2016-08-05 12:50:06

标签: ionic-framework

我是Ionic的新手,我想使用Ionic提醒来更改用户的密码。 目前我得到了这个:

let alert: Alert = Alert.create({
  title: 'Forgot Password',
  subTitle: 'Enter a new password',
  inputs: [
    {
      name: 'password',
      type: 'password',
      placeholder: 'New Password'
    },
    {
      name: 'confirm_password',
      type: 'password',
      placeholder: 'Confirm Password'
    }
  ],
  buttons: [
    {
      text: 'Change Password',
      handler: data => {
        if (data.password != data.confirm_password) {
          return false;
        } else {
            ...some requests sent...
        }
      }
    }
  ]
});

现在,如果我键入2个不同的密码,警报就不会被解雇,但我想在警报上显示一条消息。

这可以通过Ionic Alert完成吗?我没有找到任何东西。

谢谢!

1 个答案:

答案 0 :(得分:1)

最好使用$ ionicPopup,这是用于用户输入的。它需要一个范围,以便你可以做你想要的角度。不幸的是,如果密码不匹配,则无法以编程方式禁用保存按钮。

$ionicPopup.show({
    template: '<input type="password" ng-model="data.password">' +
              '<input type="password" ng-model="data.confirm_password">' +
              '<div ng-show="data.password!=data.confirm_password>Passwords do not match</div>'
    title: 'Forgot Password',
    subTitle: 'Enter a new password',
    scope: $scope,
    buttons: [
      { text: 'Cancel' },
      {
        text: 'Save',
        type: 'button-positive',
        onTap: function(e) {
          if (data.password != data.confirm_password) {
            return false;
          } else {
            ...some requests sent...
          }
        }
      }
    ]
  });
相关问题