liveBook · Manning

canDeactivate property

As explained in Pro Angular 16

The canDeactivate property is Angular route configuration that associates a route with one or more deactivation guards.

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

How Pro Angular 16 covers it

How deep it goes
Explains guard implementation, service registration, route application, and confirmation behavior without detailing Angular router internals.
Examples
Uses an editable product form, dirty-state detection, navigation buttons, and a Yes-or-No confirmation prompt.
What it assumes
Assumes Angular routing, injectable services, components, and reactive-form state such as editing and dirty.
What you can do after
Operate/configure Angular routing to prevent accidental navigation away from components containing unsaved changes.
How it connects
Connects route configuration with deactivation guards, injectable services, components, and reactive forms.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Pro Angular 16. The section links point to the parts of the book it draws on.