NG.V · Angular 22 practice question

An application needs to redirect visitors from '/menu' to either '/breakfast' or '/dinner' depending on the current time of day. How can a route definition support this dynamic redirect logic?

Choose one answer
Check answer and explanation

Correct answer: Assign a function to the route's redirectTo property

Explanation

The redirectTo property accepts a function, allowing you to compute the target redirect destination dynamically based on runtime logic.

Common trap

The path property only matches URL patterns and cannot evaluate ternary expressions to pick a redirect target. Angular routes do not have a priority flag; route matching follows definition order instead.

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

Report an error in this question