Bird
0
0

Which of the following is the correct syntax to import RouterModule with routes in an Angular module?

easy📝 Syntax Q12 of 15
Angular - Routing
Which of the following is the correct syntax to import RouterModule with routes in an Angular module?
ARouterModule(routes)
Bimports: RouterModule.forRoot(routes)
Cimports: [RouterModule.forRoot(routes)]
DRouterModule.import(routes)
Step-by-Step Solution
Solution:
  1. Step 1: Check Angular module imports syntax

    Angular modules expect an array for the imports property.
  2. Step 2: Correct use of RouterModule.forRoot

    RouterModule.forRoot(routes) returns a module configured with routes and must be inside an array.
  3. Final Answer:

    imports: [RouterModule.forRoot(routes)] -> Option C
  4. Quick Check:

    Imports must be an array with forRoot call [OK]
Quick Trick: Always wrap RouterModule.forRoot in an array for imports [OK]
Common Mistakes:
MISTAKES
  • Omitting the array brackets in imports
  • Using RouterModule.import which doesn't exist
  • Calling RouterModule as a function directly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes