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

237
Visualizações
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 Respostas
Responde à pergunta

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 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