Search code examples
javascriptangularroutesgoogle-chrome-devtoolsrefresh

window.location.reload() only refresh the home page, Why it does not refresh the other pages specifically using angular?


When I navigate from the home page to the menu page, the menu page should refresh once automatically after the navigation, but when I used the following codes, it refreshes the home page and then navigating to the menu page, where the menu page is not refreshed automatically

1)First Method:

this.router.navigate([`locations/${locationId}/menu`])
      .then(() => {
        window.location.reload();
      });

2)Second Method:

this.router.navigate([`locations/${locationId}/menu`])
      .then(() => {
        location.assign(locations/locationId/menu);
      });

Solution

  • I am not sure what you are trying to achieve but if you want to reload the menu page from the home page then you should do changes as following :

    this.router.navigate([]).then(_result => {
        window.location.replace(`locations/${locationId}/menu`);
    });