NavController cache problem


Hi everyone,
I’m going to disable native back button in Android and implement its function using nav.pop.
By the way NavController inject instance is cached on the page.
What is the best way to achieve my goal?
Sorry for my bad english.


Here is my code for better understanding.

export class MyApp {
@ViewChild(Nav) nav;
   platform: Platform
   ) {

The length of views is 1 always even though there are many views.


I suspect you have only one view in the root nav stack, which is what you’re interacting with. Why not just let the navigation system do its job instead of trying to micromanage it?


Excuse me, would you like to explain in detail?
The app is closed when back button is touched in Android system.
So I want to disable it.


Shows us please, .length says otherwise.


I was able to solve problem by using app.getActiveNav() function.


Could you share the complete solutions for future readers? Thanks.


My solution is like following:

        public navCtrl: NavController,
        public settings: SettingsService,
        public appCtrl: App,
        platform: Platform,
    ) {
            if (this.appCtrl.getActiveNav().getViews().length > 1) {