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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With