Last active
December 13, 2017 17:37
-
-
Save brachi-wernick/57897484eaf2d8b57e0b4883e5f47535 to your computer and use it in GitHub Desktop.
canDeactivateGuard-ng5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable() | |
export class CanDeactivateGuard implements CanDeactivate<UserFormComponent> { | |
canDeactivate(component: UserFormComponent): boolean { | |
if(component.hasUnsavedData()){ | |
if (confirm("You have unsaved changes! If you leave, your changes will be lost.")) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment