NG.V · Angular 22 practice question

In Angular routing, both `CanActivate` and `CanMatch` guards are used to control navigation. What is the primary functional difference between a guard implementing `CanActivate` and one implementing `CanMatch`?

Choose one answer
Check answer and explanation

Correct answer: `CanActivate` determines if a specific route *can be activated* for the current navigation, while `CanMatch` determines if a set of routes *matches* the incoming URL structure.

Explanation

`CanActivate` guards are applied to an *activated* route (or a route segment) to decide whether the navigation to that specific route should proceed. `CanMatch` guards are applied at a higher level (often to a parent route configuration or a route pattern) to determine if the incoming navigation request matches a specific route pattern defined by the guard's logic, thereby preventing the router from even looking for a specific handler.

Common trap

Candidates might confuse the execution timing. While timing is related, the core difference is the decision point: *activation* vs. *matching the route definition*.

Source: Angular Router documentation (General concepts page, as specific API comparison for v22 might be evolving) - https://angular.dev/guide/routing
Checked against the cited text on 2026-11-27.

Report an error in this question