简体   繁体   中英

Custom dialog with @HostListener in Angular

I am trying to ask the user, after making unsaved changes and refreshing the page, if he wants to discard these changes and reload the page or cancel the refresh. I want to use my own dialog instead of the browser's one. Is that possible with @HostListener('window:beforeunload')?

No, beforeunload is very limited solution, basically you can only change text in browser window.

See https://developer.mozilla.org/en-US/docs/Web/Events/beforeunload

Try CanDeactivate custom dialog

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM