Created
December 13, 2017 17:47
-
-
Save brachi-wernick/7d26270645e9ed4d66b2c13ccc1252af to your computer and use it in GitHub Desktop.
CanDeactivateGuard deneric
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<ComponentCanDeactivate> { | |
canDeactivate(component: ComponentCanDeactivate): boolean { | |
if(!component.canDeactivate()){ | |
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