Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

240
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!