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

348
Views
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 answers
Answer question

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 Report

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 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!