How to prevent pushing the current page?


#1

Hi, I have side menu with buttons, each button push to every page in app.

I want to prevent pushing the current page.

If I am in MainPage, and I click on “Main” page in side menu, i want to stay in same page without pushing it.
Any idea? Even an if statement that checking in which page I am right now.


#2

It’s not by default? Um…

public openPage(page: any): void {
  if (this.pageRoot !== page.component) {
    this.app.getComponent('nav').setRoot(page.component);
  }
}

PS The code isn’t checked


#3

I have found the solution:

	openPage(component) {
		if(this.rootPage != component) {
			let nav = this.app.getComponent('nav');
			nav.push(component);
		}
	}