'Angular refreshing page with a button

What I want to do is have a button that does the same thing as the refresh button in chrome does. I have tried location.reload(), and it doesn't seem to really do anything. Is there any way to do this?

exit() {
    location.reload();
  }

 <button [routerLink]="['/dashboard']" (click)="exit()">Exit</button>


Solution 1:[1]

Try this: window.location.reload();

Solution 2:[2]

This will reload to default route page

import { DOCUMENT } from '@angular/common';
import { Component, Inject } from '@angular/core';

@Component({
  selector: 'app-refresh-banner-notification',
  templateUrl: './refresh-banner-notification.component.html',
  styleUrls: ['./refresh-banner-notification.component.scss']
})
export class RefreshBannerNotificationComponent {

  constructor(
    @Inject(DOCUMENT) private _document: Document
  ) {}

  refreshPage() {
    this._document.defaultView.location.reload();
  }
}

Solution 3:[3]

You can remove the [routerLink]="['/dashboard']" from the button.

exit() {
   window.location.reload();
}

 <button (click)="exit()">Exit</button>

Solution 4:[4]

What about using

HTML:

<button (click)="reload()">click me</button>

TS:

reload(){
  // any other execution
  this.ngOnInit()
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CodeWarrior
Solution 2 Crystal
Solution 3 rohithpoya
Solution 4 moffeltje