Error: Uncaught (in promise): navigation stack needs at least one root page


#1

I am facing this error:
“ERROR Error: Uncaught (in promise): navigation stack needs at least one root page”

First I am on home page tab, then after clicking on user picture I am going to visit clicked user’s profile page(new component). Then I am going to click any other tab. Now when I click on home page, I cannot see home page, instead of this I am viewing clicked user’s profile page. I want to get rid of this.
I am doing this code
ionViewDidLeave(){
this.navCtrl.pop();
this.navCtrl.setRoot(TabsPage);
}


#2

It would seem to me to be a very dangerous thing to call any navigation methods inside ionViewDidLeave(). Can we achieve what you are trying to do without doing that?


#3

Did you overcome this problem?
I have the same error
In my case I just set:

app.component.ts: this.rootPage = HomePage;

and after some stuff I move to another page and here I get the error…
home.ts: nav.setRoot(OtherPage)


#4

I found a solution to my problem:

I added the following to app.component.ts;
export class MyApp
{
@ViewChild(Nav) nav: Nav;

this.nav.setRoot(this.rootPage);
}


#5

please help me, still get error when i usin ion-tabs,
Error: Uncaught (in promise): navigation stack needs at least one root page


#6

Tabs navigation can be kindof tricky. I have some experience getting around some tabs pitfalls, but it’s very difficult to provide any help without almost no specific information on your end.


#7

i get runtime error : Uncaught (in promise): navigation stack needs at least one root page,
when i call this.navCtrl.pop();