本文整理匯總了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();
}
}
}