Bird
0
0

Given the following Angular route configuration and template, what will be displayed when the URL is '/home'?

medium📝 component behavior Q13 of 15
Angular - Routing
Given the following Angular route configuration and template, what will be displayed when the URL is '/home'?
const routes = [
  { path: 'home', component: HomeComponent },
  { path: 'about', component: AboutComponent }
];

Template:
<router-outlet></router-outlet>
ANothing will be displayed because the router outlet is empty.
BThe <code>AboutComponent</code> content will be rendered inside the router outlet.
CThe <code>HomeComponent</code> content will be rendered inside the router outlet.
DAn error will occur because the route is not defined.
Step-by-Step Solution
Solution:
  1. Step 1: Match URL to route

    The URL '/home' matches the route with path 'home' which loads HomeComponent.
  2. Step 2: Render component in router outlet

    The <router-outlet> displays the matched component's template, so HomeComponent content appears.
  3. Final Answer:

    The HomeComponent content will be rendered inside the router outlet. -> Option C
  4. Quick Check:

    URL '/home' loads HomeComponent in router outlet [OK]
Quick Trick: URL matches route path to show component in router-outlet [OK]
Common Mistakes:
MISTAKES
  • Confusing which component matches the URL
  • Thinking router outlet shows all components at once
  • Assuming empty display means error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes