angularsortinghtml-tablepaginationngfor

Angular2 - Table using *ngFor with paging and sorting


I am creating a simple html table with *ngFor in Angular 2.

My question is,

Is there an easy way to add sorting and paging to the same table without using any additional third party JavaScript ?

Does angular2 provide any techniques to achieve the same ?


Solution

  • Angular does not have built-in way to sort tables. You will either have to do it yourself with wiring the events in the table headers, or use a third party component. PrimeNG does this and much more.

    Update: If you wanted to do this yourself, the equivalent of "filters" (Angular 1) is pipes in Angular 2. Here is good guide: http://voidcanvas.com/angular-2-pipes-filters/