本文整理汇总了TypeScript中@ionic/angular.AlertController类的典型用法代码示例。如果您正苦于以下问题:TypeScript AlertController类的具体用法?TypeScript AlertController怎么用?TypeScript AlertController使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AlertController类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
.catch( async error => {
this.salvaLog('auth',error,true);
const alert = await this.alertCtrl.create({
message: 'Houve um erro na sua solicitação.'+error,
buttons: [{ text: 'Ok', role: 'cancel' }],
});
await alert.present();
console.error("SMS não enviado", error);
});
示例2: chooseExport
async chooseExport() {
const alert = await this.alertController.create({
header: "Export",
message: "Choose your format for export !",
inputs: [
{
name: 'JSONRadio',
type: 'radio',
label: 'JSON',
value: 'json',
checked: true
},
{
name: 'CSVRadio',
type: 'radio',
label: 'CSV',
value: 'csv'
}
],
buttons: [
{
text: 'Cancel',
role: 'cancel',
cssClass: 'secondary',
handler: () => { }
}, {
text: 'Ok',
handler: (data: string) => {
if (data == 'json') {
this.download.exportJSON();
}
else {
this.download.exportCSV();
}
}
}
]
});
await alert.present();
}
示例3: clickMe
async clickMe() {
const alert = await this.alertController.create({
title: 'ohhhh snap',
message: 'Ive been injected via Angular keeping the old api',
buttons: [
{
text: 'Cancel',
role: 'Cancel',
handler: () => {
// console.log('cancel');
}
},
{
text: 'Okay',
role: 'Okay',
handler: () => {
// console.log('okay');
}
}
]
});
return alert.present();
}
示例4: changeUsername
// Present an alert with the current username populated
// clicking OK will update the username and display it
// clicking Cancel will close the alert and do nothing
async changeUsername() {
const alert = await this.alertCtrl.create({
header: 'Change Username',
buttons: [
'Cancel',
{
text: 'Ok',
handler: (data: any) => {
this.userData.setUsername(data.username);
this.getUsername();
}
}
],
inputs: [
{
type: 'text',
name: 'username',
value: this.username,
placeholder: 'username'
}
]
});
await alert.present();
}