import { Injectable } from '@angular/core' ; import { ActivatedRouteSnapshot , CanDeactivate , RouterStateSnapshot } from '@angular/router' ; import { MemberEditAccountComponent , MemberEditProfileComponent } from '@settings/components' ; @ Injectable ( { providedIn : 'root' } ) export class PreventUnsavedChangesGuard implements CanDeactivate < unknown > { canDeactivate ( component , currentRoute , currentState , nextState ? ) { if ( component ?. formChanged$ . value ) { return confirm ( 'Are you sure you want to continue? \nAny unsaved changes will be lost!' ) ; } return true ; } }