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

184
Visualizações
What is the difference between the navigate function and routerLink in Angular 2?

I'm following the official Angular 2 tutorial and it uses the navigate function in a very similar way as the routerLink. What is the difference between them? Which to use when?

this.router.navigate(['/detail', this.selectedHero.id]);

[routerLink]="['/detail', hero.id]"
about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

[routerLink] is an Angular directive that you can use in html for <a> or <button> elements. The directive will listen for click events and navigate to the path created with params provided to routerLink.

this.router.navigate(['/detail', this.selectedHero.id]); is used in your component or service to navigate.

routerLink directive and this.router.navigate should navigate to exactly the same url if the same arguments are specified.

about 4 years ago · Santiago Trujillo Relatório

0

routerLink is a directive that behind the scenes uses router.navigate() as well.

The value of routerLink and the function-argument in navigate is exactly the same.

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