NG.I · Angular 22 practice question

A developer is building a dashboard component. They have created a reusable `DataCard` component with the selector `app-data-card`. To display this card within the main dashboard's template, what must the developer ensure?

<app-data-card></app-data-card>
Choose one answer
Check answer and explanation

Correct answer: The dashboard component must import `DataCard` into its `imports` array to enable the usage of the `<app-data-card>` tag.

Explanation

The proper method involves ensuring the dashboard component includes `DataCard` within its `imports` array, as Angular requires knowledge of the component to render it when the corresponding selector appears in the template.

Common trap

Stating that `DataCard` must have `standalone: true` is overly restrictive; while this configuration is frequently used, the fundamental mechanism for template rendering relies on importing the component. Furthermore, suggesting the dashboard component should use `ViewChildren` describes a querying mechanism, not the process of component instantiation.

Source: Angular docs: guide/components/anatomy-of-components — Showing components in a template
Checked against the cited text on 2026-11-25.

Report an error in this question