Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

311
Views
What is the easiest way to get Current Route Path Name in Angular?

I was looking for a good way to get the current route's path name. This was the easiest I could find.

this.route.snapshot.firstChild.url[0].path

Is there a better way? Thanks!

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Thanks everyone for the answers. Here is what I found that I had to do.

router.events.subscribe((event: Event) => {
  console.log(event);
  if (event instanceof NavigationEnd ) {
    this.currentUrl = event.url;
  }
});
about 4 years ago · Santiago Trujillo Report

0

easiest way to find current path is either you directly use

this.router.url

or you can check current path on every router change using its events like this

this.router.events.subscribe((res) => { 
    console.log(this.router.url,"Current URL");
})

where router here is instance created in constructor like this

constructor(private router: Router){ ... }
about 4 years ago · Santiago Trujillo Report

0

constructor(private route:ActivatedRoute) {
  console.log(route);
}

or

constructor(private router:Router) {
  router.events.subscribe(...);
}
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!