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

327
Views
¿Cuál es la forma más fácil de obtener el nombre de ruta de ruta actual en Angular?

Estaba buscando una buena manera de obtener el nombre de ruta de la ruta actual. Este fue el más fácil que pude encontrar.

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

¿Hay una mejor manera? ¡Gracias!

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Gracias a todos por las respuestas. Esto es lo que encontré que tenía que hacer.

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

0

La forma más fácil de encontrar la ruta actual es usar directamente

 this.router.url

o puede verificar la ruta actual en cada cambio de enrutador usando sus eventos como este

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

donde el router aquí es una instancia creada en un constructor como este

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

0

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

o

 constructor(private router:Router) { router.events.subscribe(...); }
over 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!