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 322 times
2 Answers
1
You can use window.onbeforeunload.
window.onbeforeunload=()=>{
this.myFunc(); // here you can do something like creating alert
}
Himanshu Singh
- 2,083
- 1
- 4
- 14
1
Try this:
<div (window:beforeunload)="doSomething()"></div>
See this post: Is there any lifecycle hook like window.onbeforeunload in Angular2?
ng-hobby
- 1,864
- 2
- 11
- 22