Bird
0
0

You migrated a component to standalone but forgot to add 'imports' for a used Angular directive. What error will you likely see?

medium📝 Debug Q6 of 15
Angular - Standalone Components
You migrated a component to standalone but forgot to add 'imports' for a used Angular directive. What error will you likely see?
ACompilation error: Missing NgModule declaration
BTemplate parse error: Can't bind to 'ngIf' since it isn't a known property
CRuntime error: Component not found
DNo error, the directive works automatically
Step-by-Step Solution
Solution:
  1. Step 1: Recall standalone component imports

    Standalone components must explicitly import modules or directives they use.
  2. Step 2: Identify error from missing directive import

    Missing import for 'NgIf' causes a template parse error about unknown property binding.
  3. Final Answer:

    Template parse error: Can't bind to 'ngIf' since it isn't a known property -> Option B
  4. Quick Check:

    Missing directive import causes template parse error = C [OK]
Quick Trick: Import used directives in standalone components [OK]
Common Mistakes:
  • Assuming directives auto-import in standalone components
  • Confusing runtime errors with template parse errors
  • Expecting NgModule declarations to fix missing imports

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes