我有一个在添加新便笺后弹出的AlertController。它有两个选项:“新建笔记”和“查看笔记”。当按下“查看备注”时,应进入另一个页面查看备注列表。当按下“新建便笺”时,应停留在此页面以添加新便笺。那么,如何按下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();

发布于 2017-07-24 16:53:55
在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();发布于 2017-07-24 16:08:07
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);
}https://stackoverflow.com/questions/45275109
复制相似问题