Skip to main content

Difference between RouterModule.forRoot and forChild?

Mid Angular
Quick Answer RouterModule.forRoot() registers the Router service and root routes - call once in AppModule. RouterModule.forChild() registers additional routes for a lazy feature module without re-providing the Router service. Calling forRoot() in a lazy module would create a second Router instance and break routing. Feature modules always use forChild().

Answer

forRoot creates the global router services.
forChild adds child routes without recreating router instances.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice