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

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

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