Parent Component
<app-search-bar (sender)="searchVideo($event)"></app-search-bar>
<ng-container *ngFor="let video of videos | search: query; let i=index;">
...
</ng-container>
<app-pagination (sender)="setStartEnd($event)"></app-pagination>
Custom Pipe
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'search'
})
export class SearchPipe implements PipeTransform {
transform(value: any, args: any): any {
if(!value){
return null;
}
if(!args){
return value;
}
args = args.toLowerCase();
return value.filter((data: any) => {
return JSON.stringify(data).toLowerCase().includes(args);
})
}
}
Child Component (app-pagination)
<div class="pagination" *ngIf="videos.length > 3">
...
</div>
I need to get the filtered data that returned by Custom Pipe so that with the help of that I can handle the number of pages in Pagination Component.
Possibly don't use a pipe in this case. Move that logic to the parent component and share the output with whatever components in the template need it
Or, you could also use the pipe twice (although to me its logic I'd have in the parent class, not a pipe)