Bird
0
0

Which of the following is true about a service provided in an Angular module's providers array?

easy🧠 Conceptual Q2 of 15
Angular - Services and Dependency Injection
Which of the following is true about a service provided in an Angular module's providers array?
AIt creates a new instance for each component in the module.
BIt is only available to components declared outside the module.
CIt creates a new instance for each lazy-loaded module only.
DIt creates a single instance shared by all components in that module.
Step-by-Step Solution
Solution:
  1. Step 1: Understand module-level service provision

    Providing a service in a module's providers array creates one instance shared by all components declared in that module.
  2. Step 2: Clarify scope and sharing

    This instance is not recreated per component but shared within the module scope.
  3. Final Answer:

    It creates a single instance shared by all components in that module. -> Option D
  4. Quick Check:

    Module scope = single shared instance per module [OK]
Quick Trick: Module providers share one instance across module components [OK]
Common Mistakes:
MISTAKES
  • Assuming new instance per component in module
  • Confusing lazy-loaded module behavior
  • Thinking service is unavailable inside the module

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes