Can I use app.getRootNav() instead of navCtrl for the entire application?


#1

Currently my page-to-page navigation is done via the following:

export class FirstPage {
    constructor(
        public navCtrl: NavController,
    ) { }

    goPage() {
        this.navCtrl.push('LazyLoadPageName');
        // question: can I use this.app.getRootNav().push('LazyLoadPageName') instead?
    }
}

However, if I want to navigate from a tab to a page in the root nav, I need to do the following:

export class TabPage {
    constructor(
        public app: App,
    ) { }

    goPage() {
        this.app.getRootNav().push('LazyLoadPageName');
    }
}

I wonder if it’s OK to standardise the entire application to just use this.app.getRootNav(). I understand that that function may become obsolete, but there will be another function to replace it.

Is there any reason I shouldn’t do that?

Just for reads to know the difference between navCtrl and app.getRootNav()