I would like to find if the browser is refreshed in app.component with out using router navigation . How to achieve this functionality
Asked
Active
Viewed 664 times
2 Answers
1
You can use window.onbeforeunload
.
window.onbeforeunload=()=>{
this.myFunc(); // here you can do something like creating alert
}

Himanshu Singh
- 2,117
- 1
- 5
- 15
1
Try this:
<div (window:beforeunload)="doSomething()"></div>
See this post: Is there any lifecycle hook like window.onbeforeunload in Angular2?

ng-hobby
- 2,077
- 2
- 13
- 26