如何从ionic2框架警报框中获取文本字段值?
<ion-item ('click')="enterPwd();">Admin</ion-item>
enterPwd() {
let alert = this.alertCtrl.create({
title: 'Enter 4 digit PIN',
inputs: [{name:'PIN',placeholder:'pin',type:'password'}],
buttons: [{
text:'Done',
type:'button-positive',
handler: data => {
console.log('Done clicked');
//pin entered should be displayed in console..
}
}]
});
alert.present();
}
点击某个项目后,系统会调用enterPwd
,显示提醒。当用户输入他们的PIN时,我希望它显示在控制台中。
答案 0 :(得分:0)
您需要设置文本输入的名称并使用它进行访问。 您的输入是:
`inputs:[{name:'PIN',placeholder:'pin',type:'password'}`],
在你的处理程序中,
handler: data => {
console.log('Done clicked');
//TO DISPLAY PIN
console.log(data['PIN']);
}