Static injector error in Nav

Hi all…I’ve been developing an android application…In my app after a set of pages upon clicking a button , I wanted the app to go back to the homepage… lets say my last page is order.ts
In my order.ts I put

import { Nav } from 'ionic-angular';
constructor(public nav: Nav)

and upon a button click

            this.nav.setRoot(HomePage);
            this.nav.popToRoot();

these are the changes I made and now when I try to open the order.ts … this shows up:


please help…!!!

In your page, try:

import { NavController } from 'ionic-angular';

And:

  constructor(public navCtrl: NavController) {
    ...
  }

And:

this.navCtrl.setRoot(HomePage);

@robinyo when I changed to this.navCtrl.setRoot();
newerro

Just use:

this.navCtrl.setRoot(HomePage);

You don’t need -> “this.nav.popToRoot();”

this.navCtrl.setRoot(HomePage);

this is the first method I used… It displays the homepage but when I reach the homepage the sidemenu toggle doesnot work… nothing happens when i click the menu toggle…
thats why I’m trying a different approach

Ok, have you tried:

this.navCtrl.goToRoot();

or

this.navCtrl.popToRoot();

See: https://ionicframework.com/docs/api/navigation/NavController/

@robinyo I was not able to try out this.navCtrl.goToRoot(); … it gives typo error when i type this
but when I use this.navCtrl.popToRoot(); it goes back to the previous page
but the good thing there is no issue like the sidemenu not working etc…
can this this.navCtrl.popToRoot(); be used to go back to the homepage??

Did you try this one.

this.navCtrl.push(HomePage);