我有以下功能可更改Firebase用户帐户中的电子邮件。我想在完成时显示ionic2警报,无论它是否成功或出现错误。从我的代码下面我得到警报显示,但它是空白的。很可能这是Firebase承诺中的时间问题,但我不知道如何解决此问题。如何在Firebase更改后显示ionic2警报电子邮件
private doChangeEmail(data): void {
var myAlert: {
title?: string,
subtitle?: string
} = {};
this.auth.ref.changeEmail({
oldEmail: data.oldemail,
newEmail: data.newemail,
password: data.password
}, function(error) {
if (error) {
switch (error.code) {
case "INVALID_PASSWORD":
myAlert.title = 'Invalid Password';
myAlert.subtitle = 'The specified user account password is incorrect.';
break;
case "INVALID_USER":
myAlert.title = 'Invalid User';
myAlert.subtitle = 'The specified user account does not exist.';
break;
default:
myAlert.title = 'Error creating user';
myAlert.subtitle = error;
}
} else {
myAlert.title = 'DONE';
myAlert.subtitle = 'User email changed successfully!';
}
});
let alert = Alert.create({
title: myAlert.title,
subTitle: myAlert.subtitle,
buttons: [{
text: 'OK',
handler:() => {
}
}]
});
this.nav.present(alert);
}
我已经尝试过,但我得到'EXCEPTION:TypeError:无法读取属性'导航'未定义' –
在我的代码示例上面的警报DOES显示,但是空白 –