This is my first time posting a question here.
The issue I'm facing involves creating a pipe to reorder a specific column in my application (in alphabetical order). The column can have 3 statuses: -1, 0, and 1, with 0 being the default initial status. However, when I reorder the table and set the status back to 0, it doesn't reverse the order, but instead maintains the current order.
import { Pipe, PipeTransform } from '@angular/core';
import { ExternalUploads } from 'src/app/model/external/ExternalUploads ';
@Pipe({
name: 'orderpipe',
pure: false
})
export class OrderPipe implements PipeTransform {
transform(uploads: ExternalUploads [], colstat: any) {
console.log(colstat.value);
let result : ExternalUploads[] = uploads;
if(colstat.value!= 0)
if(colstat.value=== 1)
result.sort((a,b) => a.name=== b.name? 0 : a.name< b.name? -1 : 1);
else
result.sort((a,b) => a.name=== b.name? 0 : a.name> b.name? -1 : 1);
return result;
}
}
I also experimented with returning "uploads" instead of "result," which caused the table to change its order, even though it shouldn't. What steps should I take to resolve this issue?
(I am required to use a pipe and I am working with Angular 11).