本文整理汇总了TypeScript中ionic-angular.Alert.present方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Alert.present方法的具体用法?TypeScript Alert.present怎么用?TypeScript Alert.present使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ionic-angular.Alert
的用法示例。
在下文中一共展示了Alert.present方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: exibirAlertaSimNao
exibirAlertaSimNao(mensagem: string, funcaoSim: Function = null, funcaoNao: Function = null){
if(!funcaoSim){
funcaoSim = function () {return true;};
}
if(!funcaoNao){
funcaoNao = function () {return true;};
}
this.alert = this.alertCtrl.create({
title: 'Atenção',
message: mensagem,
buttons:[
{
text: 'Sim',
role: 'sim',
handler: () => funcaoSim()
},
{
text: 'Não',
role: 'nao',
handler: () => funcaoNao()
}
],
enableBackdropDismiss: false
});
this.alert.present();
}
示例2: alertThatTeamDoesNotExist
alertThatTeamDoesNotExist(teamName: string): void {
let alert: Alert = this.alertCtrl.create({
title: 'Team Does Not Exist!',
message: 'Would you like to create this team?',
buttons: [
{
text: 'NO'
},
{
text: 'YES',
handler: () => {
this.db.createNewTeam(teamName).then((team: Team) => {
console.log('team-sign-in', 'alertThatTeamDoesNotExist', '>>>', team);
if (team) this.navCtrl.push(PlayerCreationPage, { teamID: team.teamID, isAdmin: true });
else {
alert.dismiss();
this.alertThatTeamCouldNotBeCreated();
}
});
}
}
]
});
alert.present();
}
示例3:
this._platform.ready().then(() => {
if (this._alert) {
this._alert.dismiss();
}
this._alert = this._createAlert(updateAlertType);
if (this._alert) {
this._alert.present();
}
});
示例4: Promise
return new Promise((resolve,reject) => {
let alert: Alert = this.create({
title: 'แจ้งเตือน',
subTitle: message,
buttons: [
{
text: 'ตกลง',
handler: () => {
resolve();
}
}
]
});
alert.present();
alert.onDidDismiss( ()=> {
reject('onDidDismiss');
});
});
示例5: onClick
/**
* Called when a HTML element with 'clear-history' directive is clicked. <br/>
* It opens an dialog which allows the user to clear his navigation history or cancel the operation.
* @return {void}
*/
@HostListener('click', ['$event.target'])
public onClick(): void {
Analytics.trackEvent('Clear History', 'click', 'button');
let confirm: Alert = this.ctrl.create({
title: this.Text.COMPONENT_CLEAR_HISTORY_ALERT_TITLE,
message: this.Text.COMPONENT_CLEAR_HISTORY_ALERT_MESSAGE,
buttons: [
{
text: this.Text.COMPONENT_CLEAR_HISTORY_ALERT_BUTTON_NO,
handler: (): void => console.log('Clear canceled'),
},
{
text: this.Text.COMPONENT_CLEAR_HISTORY_ALERT_BUTTON_YES,
handler: (): void => this.clearHistory(),
},
],
});
confirm.present(confirm);
}
示例6: alertThatTeamAlreadyExists
alertThatTeamAlreadyExists(teamName: string): void {
let alert: Alert = this.alertCtrl.create({
title: 'Team Already Exists!',
message: 'Would you like to sign in?',
buttons: [
{
text: 'NO'
},
{
text: 'YES',
handler: () => {
this.db.checkIfTeamExists(teamName).then((team: Team) => {
if (team) this.navCtrl.push(PlayerSignInPage, { teamID: team.teamID });
else this.alertThatCouldNotSignIn();
});
}
}
]
});
alert.present();
}
示例7: alertAndDo
export function alertAndDo(
alertController: AlertController,
question: string,
button1Text: string,
action1: (data: any) => void,
button2Text?: string,
action2?: (data: any) => void
): void {
'use strict';
console.log('askAndDo(' + question + ')');
// console.log('question: ' + question);
// console.log('button1Text: ' + button1Text);
// console.log('action1: ' + action1);
// console.log('button2Text: ' + button2Text);
// console.log('action2: ' + action2);
let alert: Alert = alertController.create();
alert.setTitle(question);
if (!action2) {
alert.addButton('Cancel');
}
alert.addButton({
text: button1Text,
handler: action1
});
if (action2) {
alert.addButton({
text: button2Text,
handler: action2
});
alert.addButton('Cancel');
}
alert.present();
}
示例8: loginUser
async loginUser(): Promise<any> {
if (!this.loginForm.valid) {
console.log('Form not ready');
} else {
let loading: Loading = this.loadingCtrl.create();
loading.present();
const email: string = this.loginForm.value.email;
const password: string = this.loginForm.value.password;
try {
await this.auth.loginUser(email, password);
await loading.dismiss();
this.navCtrl.setRoot(TabsPage);
} catch (error) {
await loading.dismiss();
const alert: Alert = this.alertCtrl.create({
message: error.message,
buttons: [{ text: 'Ok', role: 'cancel' }]
});
alert.present();
}
}
}