Kind: Class
Source: Frontend/src/app/pipes/CanDeactivateGuard.ts (line 12)
Part of: Frontend
CanDeactivateGuard determines whether a route or view can be deactivated. Its canDeactivate() method returns a boolean that calling code can use to allow or block navigation away from the current state.
Methods
| Method | Signature | Returns |
|---|---|---|
canDeactivate | canDeactivate(component: ComponentCanDeactivate, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState: RouterStateSnapshot) | boolean |
Diagram
mermaidgraph LR A[Navigation request] --> B[CanDeactivateGuard] B --> C[canDeactivate()] C --> D{Boolean result} D -->|true| E[Allow deactivation] D -->|false| F[Block deactivation]
Usage
tsimport { CanDeactivateGuard } from './pipes/CanDeactivateGuard';
const guard = new CanDeactivateGuard();
if (guard.canDeactivate()) {
// Continue with navigation or cleanup.
} else {
// Keep the current view active.
}
AI Coding Instructions
- Keep
canDeactivate()returning a boolean so callers can make a direct allow-or-block decision. - Update navigation integration when changing the guard's deactivation behavior.
- Avoid adding side effects to
canDeactivate()unless the calling flow expects them. - Test both
trueandfalseoutcomes in code that depends on this guard.
Used by
26 references from 26 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.
Imported by (26)
AppRoutingModule—Frontend/src/app/app-routing.module.ts:1TranslateHandler—Frontend/src/app/app.module.ts:1MrqModule—Frontend/src/app/components/MRQ/mrq.module.ts:1BlogsModule—Frontend/src/app/components/blogs/blogs.module.ts:1ConfigurationRoutingModule—Frontend/src/app/components/configuration/configuration-routing.module.ts:1ActivitiesRouteModule—Frontend/src/app/components/dashboard/activities-route.module.ts:1DashboardModule—Frontend/src/app/components/dashboard/dashboard.module.ts:1TasksRouteModule—Frontend/src/app/components/dashboard/tasks-route.module.ts:1
…and 18 more.
Was this page helpful?