NG.V · Angular 22 practice question

A developer is writing a route guard that should send unauthenticated users to '/login' instead of merely blocking navigation. What should the guard return?

Choose one answer
Check answer and explanation

Correct answer: A UrlTree or RedirectCommand

Explanation

Returning a UrlTree or RedirectCommand from a route guard instructs the router to redirect to another route instead of blocking navigation.

Common trap

Returning false blocks navigation rather than redirecting the user to another route. Unlike redirectTo functions, route guards use UrlTree or RedirectCommand objects to perform redirects rather than raw strings.

Source: Angular docs: Control route access with guards — Route guard return types
Checked against the cited text on 2026-11-25.

Report an error in this question