How to avoid a page loading twice?


#1

Hi,

Im wondring how to avoid a page load twice?

I have a footer with an home link, if i click it couple of times its loading couple of home pages, when i click backbutton it goes trough all the home pages loaded before coming back again… i know i can make an if check to check if current page is loaded then not load it… But how to get what current page is and any example of how i can make the if check?

Thanx


#2

I think this is a road best not traveled. Can you investigate using setRoot() instead of push() instead?


#3

I have one rootpage which is the welcome page where login is, when logged inn user get to homepage which is a lazy loaded page, when click on “profile” page its lazy loading that too… But i want to avoid if i click “ProfilePage” couple of times its load it couple of times… i have tried to use this method: this.navController.getActive().name , but it always show me that this is HomePage, :confused:


#4

Then I guess somebody else is going to have to help you on this journey, because I think the way you are insisting on framing it will only end in frustration for you.


#5

How about disabling the button on click, then use a

this.navCtrl.push().then(() => this.renableButton())

Where reenableButton is a function that does just that. That way it can’t possibly be clicked twice.
Or am I misunderstanding the issue?

If so, setRoot() seems reasonable.

If you’re really averse to setRoot() for some reason, I’d suggest finding a way to enable / disable the ability to push new pages via boolean.

Getting activeNav, nav names, etc, is a rabbit hole that is most likely full of miserable rabbits.


#6

this.navCtrl.setRoot() made my day ! Thanx guy ! :slight_smile: