Skip to content

Instantly share code, notes, and snippets.

@Gummiees
Created January 28, 2022 14:26
Show Gist options
  • Save Gummiees/5901df6d781bbdc4c479c37cf1365d09 to your computer and use it in GitHub Desktop.
Save Gummiees/5901df6d781bbdc4c479c37cf1365d09 to your computer and use it in GitHub Desktop.
Display default browser popup about not saved changes when leaving the site with Angular
/* When returning false, it provokes the browser to show the popup asking if they want to leave without saving. */
@HostListener('window:beforeunload', ['$event'])
beforeUnloadHander(event) {
console.log('window:beforeunload');
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment