How to force set navRoot


#1

Hi,

I created an own loadingscreen for my app, but there is an button on the loading screen.
If you click that button he needs to open the page, but this happens:

Because I got a timeout of 3500 for redirecting the user it doesn’t go to the navRoot that needed to been set by clicking on the button.

Here is my code:

ionViewDidLoad()
    {
        // Timeout time
        let iTime = 3500;

        // Check if the filterpage needs to been shown
        if(this.localstorage.getStorage('bDontShow'))
        {
            setTimeout(() => {
                this.navCtrl.setRoot(HomePage);
            }, iTime);
        }
        else
        {
            setTimeout(() => {
                this.navCtrl.setRoot(FiltersPage)
            }, iTime);
        }
    }


    // When clicked on the button this fires
    showFilters()
    {
        this.navCtrl.setRoot(FiltersPage)
    }

#2

Some one knows the answer?


#3

maybe

this.app.getRootNav().setRoot(YourPage); // or with quote if lazy loading 'YourPage'

or maybe if the code is in app.component.ts using a viewChild to get the nav?

@ViewChild('rootNav') nav: Nav; // rootNav or the corresponding value

this.nav.goToRoot(); // maybe?

or

this.nav.root = YourPage; // maybe? with quote 'YourPage' if lazy loading