NG.V · Angular 22 practice question

A developer is writing a conditional redirect function for a route's 'redirectTo' property. Which set of return types is supported by this function?

Choose one answer
Check answer and explanation

Correct answer: A string, UrlTree, Observable, or Promise

Explanation

A redirectTo function typically returns a string or a UrlTree, and it can also return an Observable or a Promise for asynchronous redirect logic.

Common trap

Restricting the return value to a plain string ignores support for UrlTree as well as async Observable and Promise results. Returning a boolean is used by route guards to allow or block navigation, not by redirectTo functions.

Source: Angular docs: Redirecting Routes — Conditional redirects
Checked against the cited text on 2026-11-25.

Report an error in this question