CodeZettaInterview Hub

Angular · Guards · Mid-Level · Comparison

canActivate vs canMatch — when do you use each?

Short Interview Answer

canActivate runs after a route is chosen; canMatch can exclude a route from matching (useful for role-based configs).

Detailed Explanation

canMatch helps pick between alternate route configs. canActivate redirects unauthorized users. Prefer UrlTree redirects over boolean false alone.

Did you know this answer?