按下 AlertController 的选项按钮 ionic 时进入另一个页面
Enter another page when pressing AlertController's option buttons ionic
我有一个 AlertController,它会在添加新注释后弹出。它有两个选项:"new note" 和 "see notes"。当按"see notes"时,它应该进入另一个页面来查看笔记列表。当按"new note"时,它应该停留在这个添加新笔记的页面。那么,如何按alertCtrl选项按钮进入另一个页面?
现在我有:
showConfirm() {
let confirm = this.alertCtrl.create({
title: 'What do you want to do else?',
buttons: [
{
text: 'New note',
handler: () => {
console.log('New note');
}
},
{
text: 'See notes',
handler: () => {
console.log('See notes');
}
}
]
});
confirm.present();
showConfirm() {
let confirm = this.alertCtrl.create({
title: 'Use this lightsaber?',
message: 'Do you agree to use this lightsaber to do good across the intergalactic galaxy?',
buttons: [
{
text: 'Disagree',
handler: () => {
console.log('Disagree clicked');
this.seeNotes(NotesPage);
}
},
{
text: 'Agree',
handler: () => {
console.log('Agree clicked');
}
}
]
});
confirm.present();
}
seeNotes(str:any){
this.navCtrl.push(str);
}
在 handler:
方法中调用 NavController
和 push
所需的页面。
请看下面:
constructor(private navCtrl: NavController, private alertCtrl: AlertController) {}
showConfirm() {
let confirm = this.alertCtrl.create({
title: 'What do you want to do else?',
buttons: [
{
text: 'New note',
handler: () => {
this.navCtrl.push(NewNotesPage);
}
},
{
text: 'See notes',
handler: () => {
this.navCtrl.push(SeeNotesPage);
}
}
]
});
confirm.present();
我有一个 AlertController,它会在添加新注释后弹出。它有两个选项:"new note" 和 "see notes"。当按"see notes"时,它应该进入另一个页面来查看笔记列表。当按"new note"时,它应该停留在这个添加新笔记的页面。那么,如何按alertCtrl选项按钮进入另一个页面?
现在我有:
showConfirm() {
let confirm = this.alertCtrl.create({
title: 'What do you want to do else?',
buttons: [
{
text: 'New note',
handler: () => {
console.log('New note');
}
},
{
text: 'See notes',
handler: () => {
console.log('See notes');
}
}
]
});
confirm.present();
showConfirm() {
let confirm = this.alertCtrl.create({
title: 'Use this lightsaber?',
message: 'Do you agree to use this lightsaber to do good across the intergalactic galaxy?',
buttons: [
{
text: 'Disagree',
handler: () => {
console.log('Disagree clicked');
this.seeNotes(NotesPage);
}
},
{
text: 'Agree',
handler: () => {
console.log('Agree clicked');
}
}
]
});
confirm.present();
}
seeNotes(str:any){
this.navCtrl.push(str);
}
在 handler:
方法中调用 NavController
和 push
所需的页面。
请看下面:
constructor(private navCtrl: NavController, private alertCtrl: AlertController) {}
showConfirm() {
let confirm = this.alertCtrl.create({
title: 'What do you want to do else?',
buttons: [
{
text: 'New note',
handler: () => {
this.navCtrl.push(NewNotesPage);
}
},
{
text: 'See notes',
handler: () => {
this.navCtrl.push(SeeNotesPage);
}
}
]
});
confirm.present();