0

I am very new to ionic. Just learning it. Basically I have two pages, welcome and home. First welcome page gets loaded.

I want to load home page after 2-3 seconds when welcome page load. Same I have done using setTimeout in JavaScript.

ionViewDidLoad() {
    console.log('ionViewDidLoad WelcomePage');
    setTimeout(() => {
        this.navCtrl.popToRoot(home);
    }, 2500);
}

The above code not working. Seems like typo error in poptoroot. What can I try to fix this?

4
  • What's the error ? Commented Jul 7, 2017 at 1:56
  • can't find variable: home
    – Roxx
    Commented Jul 7, 2017 at 2:49
  • 1
    then home is not declared. and judging by that code you pasted is not declared on that function. Commented Jul 7, 2017 at 2:54
  • alright i have added the home page variable and it is working. Means when page loads after 2.5 sec it went to home page but when i go back to welcome page it stays there. I was hoping that whenever i move to welcome page it needs to load home page after 2.5 sec
    – Roxx
    Commented Jul 7, 2017 at 2:59

1 Answer 1

1

First you need to declare your variable "home" since it's not defined. Then to have the home page loaded when you get to the welcome page you need to use "ionViewDidEnter". Your problem is that "ionViewDidLoad" only runs once, which is when the page is created, but "ionViewDidEnter" will run even if the page is created or cached.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.