I'm trying to restrict the user to navigate to any link if there are any unsaved changes left, it works fine for most of the cases except two:
- When user clicked the Log Out
- When user clicked on a toggle button which is on layout level.
I tried to restrict the event by using Event but it is showing it as deprecated.
`
@HostListener('window:beforeunload', ['$event'])
canDeactivate(): Observable<boolean> | boolean {
if(*some condition*)
{
if(event)
{
event.preventDefault();
event.stopPropagation();
}
}
return *some condition*;
}
`
I just wanted to stop the further propagation of the request