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

214
Views
how can apply routerLinkActive directive to this.router.navigate(...) method in angular?;

we can apply routerLinkActive directive along with [routerLink] simply as:

<a [routerLink]="'/profile'" routerLinkActive="active"> My Profile </a>

of course for tag <a></a>. but if we want to navigate for action as bellow: .ts file:

navigateToMyProfile(): void {
 this.router.navigate(['/profile']);
}
And the template is:

<mat-list-item (click)="navigateToMyProfile()">

where we can apply routerLinkActive directive for above method? Best regards

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

0

Use mat-list-item as an attribute instead.

Use mat-nav-list tags for navigation lists (i.e. lists that have anchor tags).

Simple navigation lists can use the mat-list-item attribute on anchor tag elements directly

<mat-nav-list>
  <a mat-list-item routerLink="/profile" routerLinkActive="active">My Profile</a>
</mat-nav-list>
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!