Bird
0
0

What is wrong with this routes array?

medium📝 Debug Q7 of 15
Angular - Routing
What is wrong with this routes array?
const routes = [
  { path: '', component: HomeComponent },
  { path: '', component: DashboardComponent }
];
AEmpty path is not allowed in routes
BComponent names must be lowercase
CRoutes array cannot have more than one element
DDuplicate empty path causes routing conflict
Step-by-Step Solution
Solution:
  1. Step 1: Identify duplicate paths

    Both routes use empty string '' as path, causing conflict.
  2. Step 2: Understand routing behavior with duplicates

    Angular cannot decide which component to load for empty path, causing errors.
  3. Final Answer:

    Duplicate empty path causes routing conflict -> Option D
  4. Quick Check:

    Duplicate paths cause routing conflicts [OK]
Quick Trick: Each path must be unique in routes array [OK]
Common Mistakes:
MISTAKES
  • Using same path for multiple routes
  • Thinking component names must be lowercase
  • Believing empty path is disallowed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes