Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 4 routerLink - reloading current route

Tags:

angular

I would like to ask it is possible to open current page again using routerLink. I have this menu:

<ul>
  <li><a routerLink="home">Home</a></li>
  <li><a routerLink="users">Users</a></li>
</ul>

when current url is www.domain.com/users i would like to click on "Users" in menu and refresh this page. It is possible? I know that i use location.reload() but it redirect full page.

like image 202
bluray Avatar asked Mar 07 '23 07:03

bluray


1 Answers

I'm not sure if this would work in Angular 4, but in Angular 5 there is an option for reloading the active route:

RouterModule.forRoot(routes, {onSameUrlNavigation: 'reload'})
like image 105
Yakov Fain Avatar answered Mar 15 '23 15:03

Yakov Fain