The canDeactivate property associates a route with one or more deactivation guards. Angular evaluates the guard before leaving the route, allowing the application to block navigation or ask the user for confirmation. section 26.2.2
Protecting unsaved edits
An UnsavedGuard checks whether the form component is editing and its productForm is dirty. If both conditions hold, it returns a Promise and presents Yes and No responses before navigation continues. section 26.2.2
