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

236
Vistas
Angular 2 - @Input and @Output

I am not sure if I should use @Input and @Output​ since I think these decorators only work when you wan to communicate a component parent with a child one or vice versa. Can you please clarify it or correct me?

I have 3 components that are in the same level and I am looking for setting a value to a variable from component A in component B. They do no have any relationship.

Thanks

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

In short, you are right, Input() and Output() only communicate with the parent component. Your parent component could however use the Output() of component B and pass it to the Input() of component A. Using the angular life cycle hook ngOnChanges would aid with that.

There are also many ways to achieve Component A modifying a value in Component B. You could use subjects, services, parent components, as well as many other strategies. This might get into the question of how you want to manage state in your application. https://bertrandg.github.io/angular2-application-state-management-strategy/

At scale, you definitely want to be consistent with state management in your app. ngrx (https://github.com/ngrx) provides a great redux-like strategy

over 4 years ago · Santiago Trujillo 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