本文整理匯總了TypeScript中@ionic/angular.AlertController.create方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript AlertController.create方法的具體用法?TypeScript AlertController.create怎麽用?TypeScript AlertController.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ionic/angular.AlertController
的用法示例。
在下文中一共展示了AlertController.create方法的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();
}