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

225
Views
Enrutamiento angular: mantenga la URL de NavigationError

Actualmente en Angular 4, si estoy tratando de verificar que esta ruta funcione:

 /my/long/route

Si voy a él directamente y arroja un error, el Router actualizará la URL a / , ya que no se han cargado rutas válidas. Si navego a la ruta de lanzamiento de errores en la aplicación, la URL se establece en la última ruta que funcionó.

¿Hay alguna manera de mantener la URL configurada en la URL de la ruta fallida? Desde una perspectiva de registro de errores, sería bueno si pudiera usar la URL real en la que estaba el usuario en lugar de buscarla en los eventos del enrutador, y para la depuración local sería bueno poder actualizar la página en lugar de necesitar para volver a él cada vez.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Basado en el código fuente:

https://github.com/angular/angular/blob/410aa33005f2dc6f6500db71e7f019a744f909d9/packages/router/src/router.ts#L750

Realmente no veo una manera de evitar el problema.

Por ahora solo voy a hacer esto (que tiene su propio conjunto de problemas):

 this.router.events.subscribe(event => { if (event instanceof NavigationError) { this.routeFailed = true; setTimeout(() => this.location.replaceState(event.url)); } else { this.routeFailed = false; } });
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!