![](/img/trans.png)
[英]How to display selected index value in alert box using ionic 2 framework
[英]How to get a textfield value from a ionic2 framework alert box?
如何从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时,希望它显示在控制台中。
您需要设置文本输入的名称并使用它进行访问。 您的输入是:
`inputs:[{name:'PIN',placeholder:'pin',type:'password'}`],
在您的处理程序中
handler: data => {
console.log('Done clicked');
//TO DISPLAY PIN
console.log(data['PIN']);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.