Bird
0
0

Consider this routes array:

medium📝 component behavior Q5 of 15
Angular - Routing
Consider this routes array:
const routes = [
  { path: 'profile', component: ProfileComponent },
  { path: 'settings', component: SettingsComponent }
];

What happens if the URL path is '/dashboard'?
ANo component loads, navigation fails
BSettingsComponent loads
CProfileComponent loads
DApp redirects to 'profile' automatically
Step-by-Step Solution
Solution:
  1. Step 1: Check if '/dashboard' matches any route

    Neither 'profile' nor 'settings' matches 'dashboard'.
  2. Step 2: Understand Angular routing fallback

    Without a wildcard or redirect route, navigation to unknown path fails with no component.
  3. Final Answer:

    No component loads, navigation fails -> Option A
  4. Quick Check:

    Unknown path without fallback = navigation fails [OK]
Quick Trick: Unknown paths need wildcard or redirect to avoid failure [OK]
Common Mistakes:
MISTAKES
  • Assuming default component loads automatically
  • Thinking Angular redirects without config
  • Confusing path matching rules

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes