Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refresh element in angular 8 without page reload?

i'm updating database column with a button click, and i want to change the button after click. How can i achieve that without refreshing the page?

Below is my code. and it works fine only if i refresh the page.

    <button *ngIf="solved==1"  class="btn btn-success float-right">Marked</button>
    <button *ngIf="solved==0" (click)="mark()" class="btn btn-warning float-right">Mark </button>
like image 379
Invincible me Avatar asked Sep 18 '25 08:09

Invincible me


1 Answers

You can call the ngOnInit() once you are done with the processing logic of mark()

mark() {
  ...
  this.ngOnInit();
}

Also, note that trying to route back to the same page will not work as Angular will not re-route you to the same page without explicitly telling it to.

like image 103
Nicholas Kurian Avatar answered Sep 21 '25 00:09

Nicholas Kurian