Bird
0
0

Why does Angular require components to be declared in exactly one NgModule's declarations array?

hard📝 Conceptual Q10 of 15
Angular - Modules
Why does Angular require components to be declared in exactly one NgModule's declarations array?
ATo allow components to be automatically exported to all modules
BBecause components can only be used in the module where they are bootstrapped
CTo avoid duplicate component definitions and ensure a clear compilation context
DBecause services must be declared alongside components
Step-by-Step Solution
Solution:
  1. Step 1: Understand Angular's compilation model

    Angular compiles components within the context of a single module to avoid conflicts and duplication.
  2. Step 2: Explain why single declaration is required

    Declaring a component in multiple modules causes errors and ambiguity in compilation and usage.
  3. Final Answer:

    To avoid duplicate component definitions and ensure a clear compilation context -> Option C
  4. Quick Check:

    One component, one module declaration [OK]
Quick Trick: Declare each component in only one module [OK]
Common Mistakes:
  • Declaring components in multiple modules
  • Confusing declarations with providers
  • Assuming components auto-export

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes