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

76
Visualizações
Angular12 - Passing function to the component and handling result

I would like to create a common component for button which executes method, and then handles the result INSIDE child component. As I understand @Output is oneway binding, so I cannot process result of passed function, so I need to use @Input.

This is what I would like to achieve:

<my-button (action) = "exampleAction" [showConfirmation]="true">Reload</my-button>

But With @Input I need to pass functions to my component using .bind(this) and this is not elegant way. It looks like that:

<my-button (action) = "exampleAction.bind(this)" [showConfirmation]="true">Reload</my-button>

Is there any way (maybe using observables) to create simple, nice buton component which takes a method, block itself, processing method and handling it's result?

Best regards

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

0

you can combine output and input to get a two way binding. take a look to this stackblitz

<hello (action)="increment()" [resultAvailable]="resultAvailable"></hello>
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