getRootNav() deprecated, use getRootNavById(): what's the value of the root nav id?

thanks for your efforts. I’ve the same identical 1:1 issue.

I’ll follow github issue with interest.

1 Like

That should be its own issue. Please create one.
Also docs are not updated to reflect this: ion-app: Container Element for an Ionic Application

You don’t think it was deleted on purpose?
Or you mean just open an issue to fix the doc?

A patch update of a library should not delete code that might be used by users, especially not if it is documented code.

(That the docs are wrong now might be another, additional issue)

Here you go, I opened the following issue about the deletion of getActiveNav():

1 Like

An incoming patch will reinfect getActiveNav(), see

About root nav, there was already an issue about it:

3.5.3 was published yesterday, this.app.getActiveNav() is back :slight_smile:

5 Likes

Furthermore, using this.app.getRootNav().setRoot I think could be useful when your app contains a tabs and other pages not related to these

What did you do instead of using getRootNav() ?

I’m still using getRootNav(), I don’t want to use already now a workaround

It still gives a message in the console
image

So I used getActiveNavs instead, and it worked

image

Thanks!

2 Likes

I figured out how to use .getRootById() and then set root.

this.app.getRootNavById(‘n4’).setRoot(SomePage); //does not work

BUT

testNav; //declared earlier on in program

this.testNav = this.app.getRootNavById(‘n4’);
this.testNav.setRoot(LoginPage); //WORKS! no console warning

WHY ‘n4’?
console.log(this.app.getRootNav()); // it will show you the ids. they don’t seem to change

3 Likes

Why n4 is the question which is still not solved in the GitHub issue of Ionic:

In addition to my earlier comment suggesting that attempting to reach navigation stacks outside of one’s own domain is indicative of bad app design, we should not be asking “why ‘n4’?”. If something is undocumented, that means it is an internal framework implementation detail. App code must not rely on any aspect of internal framework implementation details. It becomes brittle and unmaintanable.

sorry but yes and no. I understand your point but then if it’s the case why displaying a msg telling that a method is deprecated and advising users to use another where you have to pass an/that id?

furthermore seems that even internal to the ionic team not everybody knows what is n4

I’m clearly not qualified to speak for the Ionic team, and they have many recommendations that I strongly disagree with. Suggesting people grab navigation controllers across component boundaries by any means is one of them.

no worries, you know I just like when stuffs are clear, like if a framework method is deprecated just telling what exactly should be use in the framework instead, to be sure that in the the future it is still gonna work

I understand your concern about the grabing the navigation

Well let see if one day the question gonna be answered or if the msg/recommandation gonna be modified or if the deprecated method gonna disappear before :wink:

Can you suggest an alternate storyboard/structure
For an app that goes from a page to Tabbed page then to another page that is outside of the tabbed pages?

Like this:
LoginPage => Menu-Tabs(MainPage using .getRootNavById to get to) => OtherPage

I would think about using a modal here. See this discussion for more context.

If you find any solution to this, please let us know.

1 Like