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

349
Vistas
re-resolving data upon query parameter change?

In my angular 2 projects, I wasn't able to reload the page by navigating to the same URL but with different query params. I am using resolve to pre-fetch data upon loading the page.

I am trying to get the resolver to re-fetch the data when there's URL (query param) change. How do I do this?

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Now you can with this in your route config:

{
  path: '',
  resolve: {
    data : DataResolver,
  },
  runGuardsAndResolvers: 'paramsOrQueryParamsChange',
  component: MainComponent
}
 

Passing the 'paramsOrQueryParamsChange' in your route config will trigger the DataResolver at each params or queryParams change.
you can get the resolvers data in your MainComponent like this:

ngOnInit() {
  this.activatedRoute.data.subscribe((resolversData) => {
     // is now triggered at each queryParams change
  })
}

see the doc for more info

about 4 years ago · Santiago Trujillo Denunciar

0

I think you can't get changed queryParam. I don't know if this helps you but here is my answer.

construtor(private route: ActivatedRoute) { }

ngOnInit() {

  this.route.snapshot.queryParams['something'];//when you snapshot and navigate to same url you can't get new query params, only for first initialization

  // to get new queryparams or url params also you need subscribe (for same url navigation)

  this.route.queryParams.subscribe({
      (queryParams: Params) => {
          this.yourParam = queryParams['something'];  
      }
   })
}

I think you are using snapshot instead of Observable queryParams thats why.

about 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