angular refresh page code example

Example 1: angular 8 ts refresh page

refresh(): void {
    window.location.reload();
}

Example 2: how to refresh page angular

refresh(): void {
    window.location.reload();
}

Example 3: How to Reload a Component in Angular

reloadComponent() {
  let currentUrl = this.router.url;
      this.router.routeReuseStrategy.shouldReuseRoute = () => false;
      this.router.onSameUrlNavigation = 'reload';
      this.router.navigate([currentUrl]);
  }

Example 4: refresh current component angular

reloadCurrentRoute() {
    let currentUrl = this._router.url;
    this._router.navigateByUrl('/', {skipLocationChange: true}).then(() => {
        this._router.navigate([currentUrl]);
        console.log(currentUrl);
    });
  }

Example 5: angular refresh page without reloading

this.router.navigate(['path/to'])
  .then(() => {
    window.location.reload();
  });

Example 6: angular reload component

reloadCurrentRoute() {
    let currentUrl = this.router.url;
    this.router.navigateByUrl('/', {skipLocationChange: true}).then(() => {
        this.router.navigate([currentUrl]);
    });
}