The canDeactivate method is a class-based navigation guard that decides whether Angular may deactivate a component. It receives the component being left, an ActivatedRouteSnapshot, and a RouterStateSnapshot, then returns boolean or Promise<boolean>. section 26.2.2
Blocking navigation with unsaved edits
An UnsavedGuard checks whether the form component is editing and its productForm is dirty. If both conditions hold, it prompts the user and resolves the returned promise according to the selected response. Register the guard in the module, then attach it to a route through canDeactivate. section 26.2.2
