How to refresh element in angular 8 without page reload?

会有一股神秘感。 提交于 2020-02-25 13:28:25

问题


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>

回答1:


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.



来源:https://stackoverflow.com/questions/56715352/how-to-refresh-element-in-angular-8-without-page-reload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!