0
0
Angularframework~20 mins

RouterLink for navigation in Angular - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
RouterLink Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when RouterLink is used incorrectly?
Consider this Angular template snippet:
<a routerLink="['/home']">Home</a>

What will be the result when this link is clicked?
Angular
<a routerLink="['/home']">Home</a>
AThe app navigates to the '/home' route as expected.
BThe app throws a runtime error because routerLink expects a string, not an array.
CThe link reloads the entire page instead of navigating within the app.
DNothing happens because routerLink is not a valid attribute.
Attempts:
2 left
💡 Hint
RouterLink can accept both strings and arrays for navigation paths.
📝 Syntax
intermediate
2:00remaining
Which RouterLink syntax correctly navigates to a child route?
You want to navigate to the child route '/products/details'. Which RouterLink syntax is correct?
A<a routerLink="['products/details']">Details</a>
B<a routerLink="'/products/details'">Details</a>
C<a [routerLink]="['/products', 'details']">Details</a>
D<a routerLink="products/details">Details</a>
Attempts:
2 left
💡 Hint
RouterLink array syntax splits path segments by commas.
🔧 Debug
advanced
2:00remaining
Why does this RouterLink not navigate as expected?
Given this template:
<a [routerLink]="['/dashboard']">Dashboard</a>

Clicking the link does not navigate. What is the likely cause?
Angular
<a [routerLink]="['/dashboard']">Dashboard</a>
AThe RouterModule is not imported in the Angular module.
BThe routerLink directive requires parentheses, like routerLink().
CThe path '/dashboard' is invalid because it lacks a trailing slash.
DThe link must use href instead of routerLink for navigation.
Attempts:
2 left
💡 Hint
RouterLink needs RouterModule to work properly.
state_output
advanced
2:00remaining
What is the value of the href attribute rendered by RouterLink?
Given this Angular template:
<a [routerLink]="['/profile', userId]">Profile</a>

and userId = 42, what is the href attribute value in the rendered HTML?
Angular
userId = 42
A"/profile?userId=42"
B"/profile/42"
C"/profile,userId"
D"/profile/"
Attempts:
2 left
💡 Hint
RouterLink builds the URL by joining path segments.
🧠 Conceptual
expert
3:00remaining
Which statement about RouterLink and accessibility is true?
Select the correct statement about using RouterLink for navigation and accessibility best practices.
ARouterLink disables default link behavior, so you must add ARIA labels manually.
BRouterLink automatically manages keyboard focus and ARIA roles for all links.
CRouterLink requires adding tabindex="0" to enable keyboard navigation.
DUsing RouterLink on <a> tags preserves native keyboard navigation and screen reader support.
Attempts:
2 left
💡 Hint