How to navigate the same page using routing in Ionic-4?

Viewed 2889

I want to navigate the same page using routing in Ionic 4.

I already tried this code but not work properly this.navCtrl.navigateRoot('super');

itemClicked(event) {
this.navCtrl.navigateRoot('super');

  }

I expect the page navigate to the same page in Ionic 4

3 Answers

to navigate to page use :

this.navCtrl.navigateRoot(['/route',object]);

The best approach would be to set onSameUrlNavigation, telling angular to reload. If not, a hack would be to use navigateByUrl.

this.router.navigateByUrl(`/super/${id}`);

This way, you are passing a parameter and the reloading will be done because angular detects a different url and navigates to it (if the current page does not have the same passed id though). It's not the prettiest approach in this case though. Just a work around.

{
    path: '',
    component: MyPage
  },
  {
    path: ':id',
    component: MyPage
  }
Related