Bird
0
0

Why should RouterModule.forRoot() be called only once in an Angular application?

hard🧠 Conceptual Q10 of 15
Angular - Routing
Why should RouterModule.forRoot() be called only once in an Angular application?
ABecause it disables lazy loading if called more than once.
BBecause calling it multiple times causes compile-time errors.
CBecause it automatically imports all feature modules.
DBecause it registers the router service and configures global routes once.
Step-by-Step Solution
Solution:
  1. Step 1: Understand forRoot purpose

    forRoot sets up the router service and global routes once for the app.
  2. Step 2: Effects of multiple calls

    Calling forRoot multiple times can cause unexpected behavior but not compile errors.
  3. Final Answer:

    Because it registers the router service and configures global routes once. -> Option D
  4. Quick Check:

    forRoot called once to register router service [OK]
Quick Trick: Call forRoot once to set up router service globally [OK]
Common Mistakes:
MISTAKES
  • Thinking multiple calls cause compile errors
  • Believing forRoot imports feature modules
  • Assuming it disables lazy loading

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes