Angular · Guards · Mid-Level · Live Coding
How do you implement an unsaved-changes guard?
Short Interview Answer
canDeactivate checks a component interface like hasUnsavedChanges() and confirms before leaving.
Detailed Explanation
Keep the check in the component; guard stays thin. Handle browser refresh separately with beforeunload if needed.