Unsaved edits are changes to application data that remain only in the editing form. Route deactivation guards can warn users before navigation abandons those changes. section 26.2.2
A practical Angular protection follows three steps:
- Check the component’s editing state and whether its product form is dirty. section 26.2.2
- Return a boolean or Promise<boolean>; resolve the Promise from the user’s confirmation response. section 26.2.2
- Register the guard and attach it to the route with canDeactivate. section 26.2.2
Editing a product
After opening a product’s Edit form and changing a text field, navigate elsewhere. The guard displays Yes and No responses; confirming allows navigation, while declining keeps the editing route active. section 26.2.2
