I have search for a solution for this but can not find one. What I have tried is this:
The following does print out my log statement, but does not prevent back navigation:
this.platform.backButton.subscribe(() => {
console.log('SKN.backButton.subscribe');
});
The following seems to not have any effect:
IonicModule.forRoot({
hardwareBackButton: false,
});
The following has no effect and no log is printed:
App.addListener('backButton', (data: AppUrlOpen) => {
console.log('SKN.addListener');
});
The following has no effect and no log is printed:
this.platform.ready().then(() => {
document.addEventListener('backButton', () => {
console.log('SKN.addEventListener');
});
});
How can I prevent back navigation on a certain page/component?
Thank you
Søren
This works for me on Angular and Capacitor. ie No Ionic
app.componnet.ts
ngOnInit(): void {
this.initializeApp();
}
private initializeApp(): void {
App.addListener('backButton', () => {// disable hardware back button functionality
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.