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

135
Views
Is it possible to pass dynamic data into an Angular routing module?

I have to pass data to a route (Angular v12.0.1):

// my-module-routing.module.ts
const routes: Routes = [
  { path: '', component: MyComponent, data: { key: '-> THIS HAVE TO BE DYNAMIC <-' } }
]

This dynamic data have to be passed through the call of the component, can be in HTML with RouterLink, or in TS with navigateWithHistory(), but what have to change is the data inside Route.

I don't know if this is possible, if isn't, is there alternatives?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use resolvers to load dynamic data. The Angular documentation has a good example showing how to fetch data from a service, but you can return any data.

Then you can get the data inside the component this way:

constructor(private route: ActivatedRoute) {}

ngOnInit(): void {
    this.data = this.route.snapshot.data;
}

Important to notice that the code on the resolver is going to run before the component is loaded.

about 4 years ago · Juan Pablo Isaza 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!