'How to redirect to current page after clicking alert button

Is there any way where one can redirect to or refresh current page after clicking alert button?

I want my current page reloaded after clicking on alert button, is this possible?

Thanks in advance for your contributions.



Solution 1:[1]

Simply you can use window.location.reload() to reload your current page.

Solution 2:[2]

Without seeing any code there's little help we can provide...

But you basically want something like this: StackBlitzExample of 2 way binding

ts:

objectArr = []
//update this array with from your subscribe of the http request
//something like this
update(): void {
    this.{service}.httpRequest().subscribe((result: data[]) => {
        this.objectArr = data; //bind the new data to the array you are using to create the table
    });
}

html:

<-- your table element -->
<div *ngFor="let obj of objectArr">

this is 2 way binding at it's simplest. It will regenerate the table on updating of the objectArr array.

Solution 3:[3]

I used window.location.href = './url'; and it worked fine. Atleast it refreshed the page.

Solution 4:[4]

html : 

<p (click)="deleteUser(item.id)" title="Delete">delete</p>


ts :

ngOnInit() {
    this.userService.getUser().subscribe(res => {
    this.usertable = res;
    }
}

deleteUser(id) {
       this.httpService.delete(this.url_deleteUser + id).subscribe(
       data => {
          this.getUser = JSON.stringify(data);
          this.userService.getUser().subscribe(res => this.usertable = res)
          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 Tanmay
Solution 2 Don Thomas Boyle
Solution 3 Pleasure
Solution 4 Rakesh Pathrut