PGoCareerGoCareer prep tools
Home
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Angular · Theory

Routing

← All stacks

Theory

16/43

Routing

Router maps URL → component. { path: 'marks', component: MarksPage }. routerLink="/marks" changes the URL without a full reload. <a href="/marks"> reloads and kills in-memory state.

router-outlet is where the child page paints. Params: /marks/:roll → ActivatedRoute.snapshot.paramMap.get('roll'). Guard CanActivate blocks /admin if not logged in.

Trap — wrong path order — '**' wildcard must be last. Another trap: forgetting RouterModule.forRoot in the root import.

Diagram
/login → LoginPage
  /marks → MarksPage
  /admin + CanActivate
  ** → NotFound (last)
Exam tip

routerLink vs href. One param + one guard line.

Example

const routes = [
  { path: "", component: "HomeComponent" },
  { path: "users/:id", component: "UserComponent" },
];
// RouterModule.forRoot(routes)

Routing — routes map URL paths to components; params come from the path.

Short notes

  • DefURL → component. routerLink, not href.
  • Rulewildcard last. Outlet paints the page.
  • Trap<a href> full reload.

Questions

1

routerLink vs href?

2

Where does the routed page show?

Previous← PipesNextForms →
P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.