Question presented to candidate:
"A user profile page lives at /users/:id, and it has a 'next user' button that navigates to /users/43 from /users/42. After clicking it, the page still shows user 42. Explain the ways to read route parameters in Angular, and what went wrong."
What a strong answer should cover:
- Three sources: path parameters (
:id), query parameters (?tab=posts) and matrix parameters (;mode=edit), plus staticdataand resolved data. ActivatedRoute.snapshot.paramMapis a one-time read;ActivatedRoute.paramMap/queryParamMapare observables that emit on every change.- The router reuses the component when only parameters change, so a snapshot read in the constructor goes stale β the bug in the question.
- Component input binding (
withComponentInputBinding()): route values arrive asinput()s by name and update on every navigation; a missing key is set toundefined. - Parameters are always strings (or null), so convert and validate them; parent parameters are inherited by child routes by default in Angular 22.
Clarifying questions expected:
- "Is input binding enabled in this app, or are components reading ActivatedRoute directly?"
- "Should the page reset its own state when the id changes, or keep it?"
Code / implementation expected: Yes β one component reading the same parameter three ways, navigated between ids.