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.