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

223
Visualizações
Angular how to route with parameters without changing the URL

TL;DR; I want to route to a page with parameters without the URL indicating underlying data.

I have 2 components. Component A & B. What I'd like to achieve is route to B but I need some paramteres from A. I know i can route to B by setting route like this [/B:parameter]. My problem is that it's changing the URL from localhost:4200/b to something like localhost:4200/b=?parameter. I'd like to hide parameter from users as it's:

-one: not relevant to them
-two: may contain sensitive business logic &/or data.

Currently I just set a constant to the appropriate state and read it on B's onInit but that feels very unelegant, and there should be a better, more elegant way to do things. Quite frankly it works well but I don't like it. How should I approach it?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Short answer: Passing data in route while navigate.

Explanation: You can found the data parameter in Route document (https://angular.io/api/router/Route)

Example: In routing module:

path: 'auth', component: AuthComponent, data: { type: 'admin' }

In AuthComponent you able to take the type data by using ActivateRoute

  constructor(
    private activatedRoute: ActivatedRoute
  ) {
    this.type = this.activatedRoute.snapshot.data.type;
  }

So you can ask: How to dynamically passing data while routing? Please check it out: Send data through routing paths in Angular

about 4 years ago · Juan Pablo Isaza Relatório

0

You can change the browser url without triggering any navigation by using e.g:

window.history.replaceState(undefined, '', '#newdata');

See: https://developer.mozilla.org/en-US/docs/Web/API/History/replaceState

But be really careful with that!

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