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

253
Views
Angular2 - Disable RouterLink

I want a better way to write these lines of code.

<li *ngIf="params.page > 1" class="page-item">
    <a class="page-link" [routerLink]="[]" [queryParams]="changePage(params,1)">First</a>
 </li>
<li *ngIf="!(params.page > 1)" class="page-item disabled">
     <a class="page-link">First</a>
</li>

I want to disable routerLink when !(params.page > 1). The class "disabled" is the easy way (ngClass). But the routerLink will be still active

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Try something like this

<li class="page-item">
<a class="page-link" [class.disabled]="(params.page > 1) ? true : null" 
    [routerLink]="[]" [queryParams]="changePage(params,1)">First</a>
</li>

Edit

I missed this part. :D

You also need to add class

 a.disabled {
     pointer-events: none;
     cursor:default;
 }

Try this and check whether it works or not.

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!