Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

353
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda