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

Angular · Theory

Router

← All stacks

Theory

23/43

Router

Router is the same idea as routing, said from the service side. Inject Router and call this.router.navigate(['/marks', roll]). After login, navigate. After logout, navigate to /login.

ActivatedRoute is the current page. Router is the taxi. Don’t inject ActivatedRoute when you only need to navigate.

Trap: navigateByUrl('/marks?x=1') vs navigate with queryParams — know which one you used. Another trap: navigation inside a constructor before the view exists.

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

navigate(['/marks', roll]) + why not constructor.

Example

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

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

Short notes

  • DefRouter.navigate to move. ActivatedRoute to read.
  • RuleNavigate after login/logout, not in constructor.
  • TrapMixing navigate and href.

Questions

1

Router vs ActivatedRoute?

Previous← StylingNextServices & DI →
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.