Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

78
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda