I would like to have sorting on multiple tables which are in same page. I tried to follow this package. https://github.com/VadimDez/ngx-order-pipe
When I'm sorting the table 1, table 2 is also getting sorted.How do I implement this on multiple tables separately. ?
order: any;
reverse: boolean = false;
setOrder(value: string) {
if (this.order === value) {
console.log(this.order)
this.reverse = !this.reverse;
}
this.order = value;
}
<table>
<thead>
<tr>
<th (click)="setOrder('Data.name')">Name</th>
<th (click)="setOrder('Data.age')">Age</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let Data of collection1 | orderBy: order:reverse:'case-insensitive'">
<td class="text-truncate">{{Data.name}}</td>
<td class="text-truncate">{{Data.age}}</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th (click)="setOrder('PersonData.id')">Id</th>
<th (click)="setOrder('PersonData.sport')">Sport</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let PersonData of collection2 | orderBy: order:reverse:'case-insensitive'">
<td class="text-truncate">{{PersonData.id}}</td>
<td class="text-truncate">{{PersonData.sport}}</td>
</tr>
</tbody>
</table>
this.reverseproperty. If you create separate reverse flags does it work?