Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

107
Visualizações
How to pass the filtered data which is returned from Custom Pipe to Child Component?

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.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

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)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda