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

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

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 Report

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