2017-03-31 69 views
0

我正嘗試構建一個用於向用戶發送一些指導通知的ionic2應用程序,當他點擊通知而不是主頁時,我想將用戶發送到特定頁面。 這裏是我的代碼:在ionic2通知按鈕中添加動作

public schedule(title, text) { 
     LocalNotifications.schedule({ 
      title, 
      text, 
      at: new Date(new Date().getTime() + 1* 1000)  

     }); 
    } 


LocalNotifications.on("click", (notification, state) => { 

      let alert = this.alertCtrl.create({ 
       title: this.todos[this.num].info.nom_du_musee, 
       subTitle: this.todos[this.num].info.periode_ouverture+" "+this.todos[this.num].info.adr+" site web "+this.todos[this.num].info.sitweb, 
       buttons: ["OK"] 
      }); 
      alert.present() 
     }); 




    } 

回答

0

您可以將處理程序按鈕按https://ionicframework.com/docs/api/components/alert/AlertController/

let alert = this.alertCtrl.create({ 
    title: this.todos[this.num].info.nom_du_musee, 
    subTitle: this.todos[this.num].info.periode_ouverture+" "+this.todos[this.num].info.adr+" site web "+this.todos[this.num].info.sitweb, 
    buttons: [ 
     { 
     text: 'OK', 
     handler:() => { 
      console.log('OK clicked'); 
     } 
     } 
    ] 
}); 

alert.present() 

下一個階段是用代碼來推新頁面替換的console.log補充。 。

this.navCtrl.push(DestinationPage);