Angular 5 sorting not working properly

445 Views Asked by At

In anguar 5 I referred the below link for sorting.

https://github.com/VadimDez/ngx-order-pipe

But the order which I am getting is improper. Please check the screenshot enter image description here

enter image description here I am using this code in in component:

setOrder(value: string) {
    if (this.order === value) {
      this.reverse = !this.reverse;
    }

    this.order = value;
  }

And in HTML

<thead class="text-primary">

                                <th [class.active]="order === 'theme'"
                      (click)="setOrder('theme')" class="curpointer"  width="40%">
                                    Theme 
                                    <i class="material-icons" *ngIf="order =='theme'">{{ (reverse)?'expand_less':'expand_more' }}</i>
                                </th>
</thead>
<tbody>
<tr *ngFor="let themeData of themeArr | orderBy: order:reverse:'case-insensitive' | filter:filter | paginate: { itemsPerPage: 10, currentPage: p };">


                                       <td>
                                            {{ themeData.title }}
                                        </td>
</tr>
</tbody>

Currently the result is coming but its in an improper format.

I am using angular 5.2.9 I believe we need to sort based on the type. Please guide on the same and help me accordingly.

0

There are 0 best solutions below