Skip to content

ComponentCanDeactivate

reference
1 min readUpdated

Kind: Class

Source: Frontend/src/app/pipes/CanDeactivateGuard.ts (line 6)

Part of: Frontend

ComponentCanDeactivate defines a component contract for navigation checks. Its canDeactivate() method returns a boolean that indicates whether the current component may be deactivated.

Methods

MethodSignatureReturns
canDeactivatecanDeactivate(nextUrl: RouterStateSnapshot)boolean

Diagram

mermaid
graph LR
  Component[Component] --> Contract[ComponentCanDeactivate]
  Contract --> Check[canDeactivate()]
  Check --> Result[boolean result]
  Result --> Navigation[Navigation decision]

Usage

ts
import { ComponentCanDeactivate } from './pipes/CanDeactivateGuard';

function canLeaveComponent(component: ComponentCanDeactivate): boolean {
  return component.canDeactivate();
}

// Call this before navigating away from a component.
const allowed = canLeaveComponent(currentComponent);

AI Coding Instructions

  • Implement canDeactivate() on components that need to control whether navigation can continue.
  • Return true when the component can be deactivated and false when navigation should be blocked.
  • Keep canDeactivate() focused on the navigation decision rather than changing component state.
  • Connect guard logic to this method so route changes use the component’s returned boolean.

Used by

31 references from 31 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

Imported by (31)

  • MrqDetailsComponentFrontend/src/app/components/MRQ/mrq-details/mrq-details.component.ts:1
  • BillingSettingsComponentFrontend/src/app/components/configuration/billing-settings/billing-settings.component.ts:1
  • NewBranchComponentFrontend/src/app/components/configuration/company/main-branch/new.branch.component.ts:1
  • CustomFieldsComponentFrontend/src/app/components/configuration/custom-fields/custom-fields.component.ts:1
  • DashboardSettingsDetailsComponentFrontend/src/app/components/configuration/dashboard-settings/dashboard-settings-details/dashboard-settings-details.component.ts:1
  • DoubleWayAuthenticationComponentFrontend/src/app/components/configuration/double-way-authentication/double-way-authentication.component.ts:1
  • DynamicValidationComponentFrontend/src/app/components/configuration/dynamic-validation/dynamic-validation.component.ts:1
  • IntegrationWithCrmsComponentFrontend/src/app/components/configuration/integration-with-crms/integration-with-crms.component.ts:1

…and 23 more.

Was this page helpful?

Download as PDF