I went to this link How can I handle browser tab close event in Angular? Only close, not refresh
But I don't know how to achieve this in Angular 4.
I am not able to identify when page is refreshed and when tab or browser is closed.
Because in both cases it fires "window:unload" and window:beforeunload" event so it's hard to identify.
Actually I want to fire logout event when browser or tab is closed but it fire in case of refresh as well.
Following is my code.
@HostListener('window:unload', ['$event'])
unloadHandler(event) {
this.recordLogOut();
}
Any input/direction/help would be appreciated.