2

Are there any advantages of applying @Input/Output vs Services (Publish/Subscribe) in Angular? Input Output can only talk between Parent-Child; however Services can do both, (Parent-Child, Sibling, Different components).

So as business requirements, architecture changes, seems like Services have more flexibility? And services more Microservices? So why use Input/Output?

I am trying to learn benefits, and good principles.

1
  • Depends on what you're doing. What's an example of what you're experiencing? Commented Nov 15, 2019 at 22:57

1 Answer 1

1

There are a lot of factors that go into that decision. There is no 'right' answer.

For example for a lot of your 'dumb' components you should be using inputs/outputs as you generally don't want them to know too much about your application structure and have a bunch of dependencies... also communication through services doesn't generally work well for component reuse. Say for example I have 2 of the same child component on a page that I want to display different data. How do I do that if I am communicating with them via services? It is simple with inputs/outputs.

Higher level components are more likely to need to interact and communicate with services.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.