Bird
0
0

Why do Angular apps use services instead of putting all code inside components?

easy🧠 Conceptual Q11 of 15
Angular - Services and Dependency Injection
Why do Angular apps use services instead of putting all code inside components?
ATo make components load slower
BTo share data and logic across components easily
CTo avoid using TypeScript
DTo write more HTML code
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of services

    Services hold shared data and logic that multiple components can use.
  2. Step 2: Compare with components

    Components focus on showing the UI, not on sharing data or logic.
  3. Final Answer:

    To share data and logic across components easily -> Option B
  4. Quick Check:

    Services share data and logic = A [OK]
Quick Trick: Services share logic, components show UI [OK]
Common Mistakes:
MISTAKES
  • Thinking services slow down the app
  • Believing services replace HTML
  • Confusing services with components

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes