Bird
0
0

What will happen if you try to use a standalone component without importing it in another standalone component's imports array?

medium📝 component behavior Q5 of 15
Angular - Standalone Components
What will happen if you try to use a standalone component without importing it in another standalone component's imports array?
@Component({
  selector: 'app-parent',
  standalone: true,
  template: ``,
  imports: []
})
export class ParentComponent {}
AAngular will throw a template parse error because app-child is not imported.
BThe app-child component will render normally without import.
CAngular will automatically import app-child for standalone components.
DThe parent component will fail to compile due to missing selector.
Step-by-Step Solution
Solution:
  1. Step 1: Understand standalone component imports

    Standalone components must explicitly import other standalone components they use in their imports array.
  2. Step 2: Analyze missing import effect

    Without importing app-child, Angular cannot recognize its selector and throws a template parse error.
  3. Final Answer:

    Angular throws template parse error due to missing import -> Option A
  4. Quick Check:

    Missing import causes error = Angular will throw a template parse error because app-child is not imported. [OK]
Quick Trick: Always import standalone components you use in imports array [OK]
Common Mistakes:
  • Assuming Angular auto-imports standalone components
  • Thinking missing import still renders component
  • Confusing compile errors with runtime errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes