Bird
0
0

Why does this Angular SPA navigation fail?

medium📝 Debug Q7 of 15
Angular - Routing
Why does this Angular SPA navigation fail?
<a href='/profile'>Profile</a>

Clicking it reloads the page instead of loading ProfileComponent dynamically.
AUsing href instead of routerLink causes full page reload
BProfileComponent is missing a selector
CRouterModule is not imported
DAngular does not support anchor tags
Step-by-Step Solution
Solution:
  1. Step 1: Understand anchor tag behavior

    Using href causes browser to reload page on click.
  2. Step 2: Angular routing solution

    Using routerLink directive prevents reload and loads component dynamically.
  3. Final Answer:

    Using href instead of routerLink causes full page reload -> Option A
  4. Quick Check:

    href causes reload, routerLink prevents it [OK]
Quick Trick: Use routerLink for SPA navigation, not href [OK]
Common Mistakes:
MISTAKES
  • Thinking missing selector causes reload
  • Assuming RouterModule import fixes href usage
  • Believing Angular disallows anchor tags

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes