내 홈 페이지 내에서 registerbackbuttonaction
을 덮어 쓰고 내 홈 페이지에서 다른 페이지로 이동하면 unregistering
내 백 버튼 조치 ionViewDidLeave 잘 작동합니다.모델로 이동하거나 사이드 메뉴에서 다른 페이지로 이동할 때 장치 백 버튼을 등록 취소하는 방법
문제는 :
나는 사이드 메뉴 항목에 대한 나의
app.component.ts
파일 내부에this.nav.push("pagename")
을 작성했습니다. 이 때문에 나는 다시 장치 다시 버튼을 over ridding 후 장치 다시 버튼 onclick 갈 수 없습니다.내 전체 응용 프로그램에서 over-ridding back button 기능을 제거하면 예상 한 결과를 얻고 있습니다.
또한
model
페이지를 열면 내 라이프 사이클 이벤트가 트리거되지 않습니다.
여기에 내가 그것을 뒤로 버튼을 등록 취소되지만 모델과 sidemenu 부분이 작동하지 않습니다 밀어 않는 경우
TS는 위의 코드는 잘 작동
initializeBackButtonCustomHandler(){
let self = this
this.platform.ready().then(() => {
self.unregisterBackButtonAction = self.platform.registerBackButtonAction(() => {
if (this.menuCtrl.getOpen() != null) {
this.menuCtrl.close();
return
}else if(this.modal && this.modal.index === 0) {
console.log("invoking modal value")
/* closes modal */
// this.modal.dismiss();
this.viewCtrl.dismiss();
return
}
this.toast = this.toastCtrl.create({
message: "Press back again to exit the app",
position: 'bottom',
duration: 1500
});
this.toast.present();
this.clickCount = this.clickCount + 1;
this.toast.onDidDismiss(() => {
this.clickCount = 0;
})
if(this.clickCount == 2){
this.clickCount = 0;
this.toast.dismiss();
this.platform.exitApp();
}
}, 10)
});
}
ionViewDidEnter(){
this.initializeBackButtonCustomHandler();
}
ionViewDidLeave() {
this.unregisterBackButtonAction && this.unregisterBackButtonAction();
}
파일 내 코드입니다.
내가 등록 취소해야하는 이유는 우리가 모든 페이지를 헨들링 할 필요가 없기 때문에 backbutton pop()의 기본 동작이며 한 페이지에서 registerbackbuttonaction을 수행하면 나머지 페이지에도 영향을 미치기 때문입니다. –