Angular · Middle · Question 33 of 75
How do you warn the user before leaving a page with unsaved changes?
- ✓Correct answer: A
canDeactivateguard that checks the component state and asks for confirmation - 2A
canActivateguard on the next route - 3A
beforeunloadlistener handles in-app navigation too
Explanation
CanDeactivateFn<EditPage> receives the component instance and can return confirm(...). beforeunload only covers closing or reloading the tab, not router navigation.