Hello,
Just recently migrated to Ionic 4, using the sidemenu template.
As this is for a hybrid app, I am relying on the stack style navigation as per v3.
The issue I am seeing is if I use the hardware back button to navigate, it goes through the entire navigation history, as it is now using angular-router. It should just go back to the root page.
I need the functionality available in v3 to be maintained, as navigating back through the entire history isn’t suitable for hybrid apps, in my opinion.
app.component.html
Menu {{p.title}} Settings Logoutimport { Component } from ‘@angular/core’;
import { Platform, NavController, } from ‘@ionic/angular’;
import { SplashScreen } from ‘@ionic-native/splash-screen/ngx’;
import { StatusBar } from ‘@ionic-native/status-bar/ngx’;
import { interval } from ‘rxjs’;
import { Router } from ‘@angular/router’;
@Component({
selector: ‘app-root’,
templateUrl: ‘app.component.html’//,
})
export class AppComponent {
public appPages = [
{
title: ‘All Animals’,
url: ‘/animal-list’
},
{
title: ‘BEEP’,
url: ‘/beep/home’
},
{
title: ‘Pending’,
url: ‘/pending’
}
];
isActive: boolean = true;
constructor(
private platform: Platform,
private splashScreen: SplashScreen,
private statusBar: StatusBar,
public nav: NavController,
public router: Router
) {
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
this.statusBar.styleDefault();
this.splashScreen.hide();
console.log("Initialising App");
this.nav.navigateRoot('/');
});
}
logout() {
this.nav.navigateRoot('/login/1');
}
settings() {
this.nav.navigateRoot('/settings');
}
navigate(route) {
// this.nav.navigateRoot(route);
// this.router.navigate([route], {replaceUrl:true});
this.router.navigate([route]);
// this.location.replaceState(route);
}
}
Ionic:
Ionic CLI : 5.2.4 (C:\Users\craig\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : @ionic/angular 4.6.2
@angular-devkit/build-angular : 0.13.9
@angular-devkit/schematics : 7.3.9
@angular/cli : 7.3.9
@ionic/angular-toolkit : 1.5.1
Cordova:
Cordova CLI : 8.1.2 (cordova-lib@8.1.1)
Cordova Platforms : android 7.1.4
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 9 other plugins)
Utility:
cordova-res : 0.3.0 (update available: 0.6.0)
native-run : 0.2.6 (update available: 0.2.8)
System:
NodeJS : v8.11.1 (C:\Program Files\nodejs\node.exe)
npm : 6.4.1
OS : Windows 10