Routing: Angular 22 practice questions
Routing is 10% of the free Angular 22 mock (5 of 50 questions). Pick an answer to see right away whether it is correct, with the explanation and the documentation section it comes from.
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?
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.
NG.V · Angular 22 practice question
Which combination of route details can a developer inspect directly on a route snapshot?
Check answer and explanation
Correct answer: Route parameters, route data, and child routes
Explanation
A route snapshot holds essential state for the route at that moment, including its parameters, data, and child routes.
Common trap
Snapshots provide structured route metadata including parameters, data, and child routes, not just a raw URL string. Snapshots represent router state rather than exposing component template references or private service instances.
Source: Angular docs: Read route state — Understanding route snapshots
Checked against the cited text on 2026-11-25.
NG.V · Angular 22 practice question
A developer is comparing '<a href="https://www.angular.dev/essentials">' with a relative navigation path in an Angular app. What distinguishes an absolute URL from a relative URL?
<a href="https://www.angular.dev/essentials">Angular Essentials Guide</a>
<a href="/essentials">Angular Essentials Guide</a>
Check answer and explanation
Correct answer: An absolute URL includes the full path with the protocol and root domain, whereas a relative URL is resolved relative to the current route's location
Explanation
Absolute URLs specify the full address including the protocol and root domain, while relative URLs define navigation paths relative to the current route's location.
Common trap
External absolute URLs with protocols use standard href attributes rather than routerLink. This reverses the two definitions: the protocol and root domain belong to absolute URLs, not relative ones.
Source: Angular docs: Navigate to routes — Using absolute or relative links
Checked against the cited text on 2026-11-25.
NG.V · Angular 22 practice question
A component reads a route parameter from a route snapshot during initialization, then the user navigates to the same component with a different parameter value. Why does the displayed value fail to update?
Check answer and explanation
Correct answer: Route snapshots are static and do not reflect future changes to the route
Explanation
Route snapshots capture router state at a single point in time; they are static and will not reflect subsequent changes when the same route updates.
Common trap
Snapshots do include route parameters, so missing path parameter support is not the reason the UI stays stale. Snapshots remain readable after change detection; they simply retain the initial values rather than updating reactively.
Source: Angular docs: Read route state — Understanding route snapshots
Checked against the cited text on 2026-11-25.
NG.V · Angular 22 practice question
Inside a 'redirectTo' function, a developer tries to inspect the route's resolved title and lazy-loaded component on the 'ActivatedRouteSnapshot' argument, but they are unavailable. Why does this happen?
Check answer and explanation
Correct answer: Some route data, such as resolved titles and lazy-loaded components, is not accurately known during the route matching phase
Explanation
Because redirectTo runs during route matching, only partial ActivatedRouteSnapshot data is available; details like resolved titles and lazy-loaded components are not yet accurately known.
Common trap
Redirect functions do receive partial ActivatedRouteSnapshot data, so claiming none is provided is inaccurate. Routing strategy (hash vs path) does not change the lifecycle timing of when titles are resolved or lazy components are loaded.
Source: Angular docs: Redirecting Routes — Conditional redirects
Checked against the cited text on 2026-11-25.
NG.V · Angular 22 practice question
A developer needs to read information associated with the currently active route inside a component. Which service from '@angular/router' should be injected?
import {Component, inject} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
@Component({
selector: 'app-product',
template: `<p>Product details</p>`,
})
export class Product {
private route = inject(ActivatedRoute);
}
Check answer and explanation
Correct answer: ActivatedRoute
Explanation
ActivatedRoute is the '@angular/router' service that exposes all details associated with the currently active route.
Common trap
RouteConfig is an outdated or non-existent service name for reading live route state in Angular. RouterOutlet is a directive that marks where routed components render in the template, not the service for reading route state.
Source: Angular docs: Read route state — Get information about the current route with ActivatedRoute
Checked against the cited text on 2026-11-25.
NG.V · Angular 22 practice question
A route configuration places a general wildcard or parameterized route above a more specific static route, causing the static route to never activate. Why does route order matter in Angular?
Check answer and explanation
Correct answer: Angular uses a first-match wins strategy and stops checking once a route path matches
Explanation
Angular uses a first-match wins strategy and stops checking further routes as soon as one matches, so more specific routes must be declared before less specific ones.
Common trap
A last-match wins rule would make the bottom route win, which is the opposite of how Angular's router evaluates route arrays. The router preserves the exact array order you define rather than sorting routes alphabetically.
Source: Angular docs: Define routes — How Angular matches URLs
Checked against the cited text on 2026-11-25.
NG.V · Angular 22 practice question
A route configures two asynchronous guards, '[authGuard, roleGuard]', that each return an Observable. How does the Angular router execute them?
Check answer and explanation
Correct answer: It starts them in array order and runs them concurrently without waiting for the first to finish
Explanation
The router invokes guards in array order, but it does not wait for one asynchronous guard to finish before starting the next, so Promise- and Observable-based guards run concurrently.
Common trap
Many developers assume array order implies sequential awaiting, but Angular starts each guard immediately without blocking on earlier async results. All guards in the array are evaluated for the route rather than stopping after the first asynchronous guard.
Source: Angular docs: Control route access with guards — Applying guards to routes
Checked against the cited text on 2026-11-25.
NG.V · Angular 22 practice question
A route requires both an authentication check and a role permission check before activation. How are multiple guards configured on a single route definition?
Check answer and explanation
Correct answer: Specify the guards in an array on the route's guard property
Explanation
Route configurations accept guards as arrays so you can attach multiple guards to the same route.
Common trap
Angular route guard properties expect function references in an array, not string expressions separated by pipes. JavaScript object literals cannot have duplicate keys of the same name without overwriting the earlier property.
Source: Angular docs: Control route access with guards — Applying guards to routes
Checked against the cited text on 2026-11-25.
NG.V · Angular 22 practice question
Given this standalone component, how does it trigger programmatic navigation to the '/profile' route when the button is clicked?
import {Router} from '@angular/router';
import {Component, inject} from '@angular/core';
@Component({
selector: 'app-dashboard',
template: `<button (click)="goToProfile()">View Profile</button>`,
})
export class AppDashboard {
private router = inject(Router);
goToProfile() {
this.router.navigate(['/profile']);
}
}
Check answer and explanation
Correct answer: It injects Router and passes an array of path segments to router.navigate()
Explanation
Injecting Router with inject(Router) and passing an array of path segments to router.navigate() is the standard way to navigate programmatically in Angular.
Common trap
ActivatedRoute exposes state about the active route rather than providing a navigate() method for triggering new navigations. Angular's Router manages client-side navigation through its own API rather than asking components to mutate window.location.pathname directly.
Source: Angular docs: Navigate to routes — `router.navigate()`
Checked against the cited text on 2026-11-25.
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?
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.
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?
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.