After creating a custom pipe, I incorporated it into my project:
@Pipe({ name: 'orderBy' })
export class OrderByPipe implements PipeTransform {
transform(items: any[], orderBy: string): any[] {
if (items && items.length > 1) {
console.log('items -> ', items);
}
console.log('return -> items -> ', items);
return items;
}
}
Within a component, the pipe is utilized in this manner:
<tr *ngFor="let item of items | orderBy:'title'" class="myclass">
Despite the table rows showing up correctly, an issue arises where the length of the items
array within the pipe always appears as zero. The console output upon returning from the pipe, however, indicates that the array is populated with objects. What could be causing this discrepancy?