angularpaginationrouterlink

Setting up Paging with links in Angular template


I have tried the below solution :

{{page}}

If I remove the {{page}} in the routerlink it works, otherwise it gives error. But I need of course the page number inside the link so that I may direct to the proper page. How can I achieve that?


Solution

  • Try like this:) You can pass routerLink argument like array, where is second param can be variable.

    <a style="display:inline-block" *ngFor="let page of pages" [routerLink]="['/searchflights',page]">
               {{page}}
    </a>