Typescript

How to reload the current route with the angular 2 router

25 September 2026 · 5 min read

How to reload the current route with the angular 2 router

Reloading a route in Angular is a common task that can sometimes seem tricky due to the framework’s single-page application (SPA) nature. While Angular strives to avoid full page reloads for performance reasons, there are situations where refreshing the current route is necessary, such as updating data after a form submission or reflecting changes made elsewhere in the application. This post explores several effective techniques for reloading the current route in Angular 2+, offering solutions for various use cases and explaining the nuances of each approach.

Using the Router.navigate() Method

The Router.navigate() method provides a flexible way to reload the current route. By navigating to the current URL, Angular will trigger a reload of the component and its associated data. This method is particularly useful when you want to trigger a lifecycle hook like ngOnInit().

Example:

constructor(private router: Router) { }<br></br> reloadRoute() {<br></br>   this.router.navigate([this.router.url]);<br></br> }Employing the onSameUrlNavigation Property

Introduced in Angular 5.1, the onSameUrlNavigation property allows you to control how the router handles navigation to the same URL. Setting this property to ‘reload’ in your RouterModule configuration tells Angular to reload the component whenever the route remains the same but parameters or query strings change.

Example (in app.module.ts):

imports: [RouterModule.forRoot(routes, {onSameUrlNavigation: 'reload'})]This approach is particularly useful for dynamic routes where changes in parameters might not otherwise trigger a component reload.

Leveraging Window.location.reload()

For scenarios where a full page refresh is acceptable or desired, you can use the standard JavaScript window.location.reload() method. This approach bypasses Angular’s routing mechanism and forces a full browser refresh, effectively reloading all resources.

Example:

reloadPage() {<br></br>   window.location.reload();<br></br> }Use this method with caution, as it can impact performance and user experience if overused. It’s best suited for scenarios where a full refresh is explicitly required, such as after clearing browser cache or updating critical application data.

Implementing a Route Reuse Strategy

For more granular control over route reloading, you can create a custom route reuse strategy. This approach lets you define specific conditions under which routes should be reloaded or reused, offering maximum flexibility and control over the reloading behavior.

While this approach is more complex, it allows you to optimize performance and tailor the reload behavior precisely to your application’s requirements. You can implement a custom RouteReuseStrategy to determine when a component should be recreated or reused based on specific criteria, like route parameters or data changes. This advanced technique is ideal for applications that require highly optimized route management.

Choosing the Right Approach

  • For simple scenarios, Router.navigate() offers a straightforward solution.
  • onSameUrlNavigation is useful for handling parameter changes.
  • window.location.reload() is suitable for full page refreshes.
  • Custom route reuse strategies provide the most control but require more complex implementation.

Choosing the right approach depends on the specific needs of your application. Consider factors such as performance, user experience, and the complexity of your routing setup.

Placeholder for infographic illustrating different route reloading methods and their impact.

  1. Identify the scenario that requires route reloading.
  2. Choose the most suitable method based on your needs.
  3. Implement the chosen method in your Angular application.
  4. Test thoroughly to ensure the desired behavior.

Understanding user intent is crucial for crafting relevant and engaging content. When searching for “Angular route reload,” users typically seek solutions for refreshing data, reflecting changes, or fixing display issues. By providing clear and concise solutions to these specific needs, we can create content that effectively addresses user intent and provides genuine value.

Angular experts recommend using the Router.navigate() method as the primary approach for most route reloading scenarios. It offers a good balance between simplicity and functionality, making it suitable for a wide range of applications.

Learn more about Angular Routing.FAQ

Q: Why does Angular avoid full page reloads?

A: Angular is a single-page application framework, which means it aims to update the content dynamically without reloading the entire page. This approach improves performance and provides a smoother user experience.

By understanding the nuances of Angular’s routing system and leveraging the appropriate techniques, you can effectively reload routes and ensure your application reflects the latest data and changes. Remember to choose the method that best suits your specific needs and consider the implications for performance and user experience. Explore these methods further in the official Angular documentation (https://angular.io/guide/router) and resources like Stack Overflow (https://stackoverflow.com/). This approach is particularly useful for dynamic routes where changes in parameters might not otherwise trigger a component reload. Consider performance implications when using window.location.reload(). Deep dive into custom route reuse strategies for more complex scenarios. For further learning, explore advanced routing concepts such as lazy loading and route guards (https://angular.io/guide/routerlazy-loading-route-configuration).

Question & Answer :
I am using angular 2 with hashlocation strategy.

The component is loaded with that route:

"departments/:id/employees" 

So far fine.

After I do a successful batch save of multiple edited table rows I want to reload the current route URL via:

this.router.navigate([`departments/${this.id}/employees`]); 

But nothing happens, why?

Create a function in the controller that redirects to the expected route like this:

redirectTo(uri: string) { this.router.navigateByUrl('/', { skipLocationChange: true }).then(() => { this.router.navigate([uri])}); } 

Then you use it like this

this.redirectTo('//place your uri here'); 

This function will redirect to a dummy route and quickly return to the destination route without the user realizing it.