3

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

Bulat
  • 720
  • 7
  • 15
diksha
  • 35
  • 1
  • 6

3 Answers3

-1

to navigate to page use :

this.navCtrl.navigateRoot(['/route',object]);
keshav godani
  • 303
  • 2
  • 4
  • 15
-1

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.

Vitor Antonio
  • 134
  • 2
  • 5
-1
{
    path: '',
    component: MyPage
  },
  {
    path: ':id',
    component: MyPage
  }
Nawaz Shareef
  • 23
  • 1
  • 7
  • Please don't post only code as an answer, but also provide an explanation of what your code does and how it solves the problem of the question. Answers with an explanation are usually more helpful and of better quality, and are more likely to attract upvotes – Ran Marciano Mar 10 '21 at 05:50