Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
Angular Routing: Keep NavigationError url

Currently in Angular 4, if I'm trying to verify this route is working:

/my/long/route

If I go to it directly and it throws an error, the Router will update the url to /, since no valid routes have loaded. If I navigate to the error throwing route in the application, the url is set to the last route that worked.

Is there a way I can keep the url set on the failed route url? From an error logging perspective, it would be nice if I could just use the actual url the user was on opposed to fishing for it in the router events, and for local debugging it would be nice to be able to refresh the page opposed to needing to navigate back to it every time.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Based on the source code:

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

I don't really see a way of getting around the issue.

For now I'm just going to do this (which has it's own set of problems):

    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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda