How to reload page the whole page in Angular 2? [closed]

我与影子孤独终老i 提交于 2019-12-20 08:59:12

问题


How can I reload the current page on Angular via TypeScript?

I don't want to change the URL parameters, only to reload.


回答1:


This should technically be achievable using window.location.reload():

HTML:

<button (click)="refresh()">Refresh</button>

TS:

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

Update:

Here is a basic StackBlitz example showing the refresh in action. Notice the URL on "/hello" path is retained when window.location.reload() is executed.

Hopefully that helps!



来源:https://stackoverflow.com/questions/43985752/how-to-reload-page-the-whole-page-in-angular-2

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