gpt4 book ai didi

typescript - Ionic 3 - 在警报 Controller 中设置 id 值

转载 作者:搜寻专家 更新时间:2023-10-30 21:13:41 26 4
gpt4 key购买 nike

是否可以在 ionic 3 的警报 Controller 中设置 id 值?

通常在 html 标签中我们可以设置 id 值。但是在这里显示警报对话框时,我们在 ts 代码中使用警报 Controller 。那么有没有办法在alert controller中设置id呢?

最佳答案

尝试下面的例子并查看文档 here

import { AlertController } from 'ionic-angular';

constructor(private alertCtrl: AlertController) {

}

presentAlert() {
let alert = this.alertCtrl.create({
title: 'Low battery',
subTitle: '10% of battery remaining',
buttons: ['Dismiss']
});
alert.present();
}

presentConfirm() {
let alert = this.alertCtrl.create({
title: 'Confirm purchase',
message: 'Do you want to buy this book?',
buttons: [
{
text: 'Cancel',
role: 'cancel',
handler: () => {
console.log('Cancel clicked');
}
},
{
text: 'Buy',
handler: () => {
console.log('Buy clicked');
}
}
]
});
alert.present();
}

presentPrompt() {
let alert = this.alertCtrl.create({
title: 'Login',
inputs: [
{
name: 'username',
placeholder: 'Username'
},
{
name: 'password',
placeholder: 'Password',
type: 'password'
}
],
buttons: [
{
text: 'Cancel',
role: 'cancel',
handler: data => {
console.log('Cancel clicked');
}
},
{
text: 'Login',
handler: data => {
if (User.isValid(data.username, data.password)) {
// logged in!
} else {
// invalid login
return false;
}
}
}
]
});
alert.present();
}

关于typescript - Ionic 3 - 在警报 Controller 中设置 id 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50502820/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com