本文整理汇总了TypeScript中ionic-angular/index.Alert类的典型用法代码示例。如果您正苦于以下问题:TypeScript Alert类的具体用法?TypeScript Alert怎么用?TypeScript Alert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Alert类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
this.authService.loginUser(loginData.userId, loginData.userPassword).then((result) => {
if (result) {
//console.log(result);
/*this.nav.push(WelcomePage, {
info: result
});*/
if(result['type'] == "student"){
this.nav.setRoot(WelcomeStudentPage, { info: result });
}
if(result['type'] == "teacher"){
this.nav.setRoot(WelcomeTeacherPage, { info: result });
}
} else {
let alert = Alert.create({
title: 'Login failure!',
subTitle: 'Please check your userId and Password and log in back!',
buttons: [{
text: 'OK',
handler: () => {
//console.log('inside the button click');
this.nav.pop();
}
}]
});
this.nav.present(alert);
}
}).catch((err) => {
示例2: showAlert
public showAlert(title:string, message:string) {
let alert = Alert.create({
title: title,
subTitle: message,
buttons: ['OK']
});
this._nav.present(alert);
}
示例3: logout
logout() {
console.log('inside the log out call' + this.userInfo.userId);
this.authService.loginOut(this.userInfo);
let alert = Alert.create({
title: 'Logout confirmation!',
subTitle: 'Will be Log out from the Site!',
buttons: [{
text: 'OK',
handler: () => {
this.nav.setRoot(TabsPage);
}
}]
});
this.nav.present(alert);
}