NG.V · Angular 22 practice question

In Angular 22, `withComponentInputBinding()` is added in `provideRouter()`, and a route such as `path: 'detail/:id'` maps the `:id` parameter to a component input. The input itself may use a `transform` on `input()` / `@Input()`, not on the route `data` object. If `DetailComponent` declares `itemId = input<string>()` but the router state does not provide a value for `itemId`, what is the likely outcome in the component?

Choose one answer
Check answer and explanation

Correct answer: The `itemId` property in `DetailComponent` will receive `undefined`, and the component logic must handle this gracefully.

Explanation

When using mechanisms like `withComponentInputBinding()` (which relies on transforming data provided in the route/data object), if the expected data key is missing or the transformation results in a lack of value, the bound input property in the component will typically resolve to `undefined` (unless explicit defaults are set in the component). The Angular Router framework generally allows the navigation to complete even if an optional input binding receives no value, passing `undefined`.

Common trap

Option A suggests an immediate crash, which is too harsh for missing optional bindings in modern Angular routing patterns. Option C suggests an automatic fallback which is not a default behavior of this binding mechanism.

Source: Routing Guide (Specific details on input binding mechanism would be found within the documentation related to route data transformation, referencing https://angular.dev/guide/routing)
Checked against the cited text on 2026-11-27.

Report an error in this question