Dears, The Golden Rules about web component interaction are:
This pattern worked for us in many projects (YUI, JQuery, ...) What about Angular2?
Should we use:
or Input/Output?
First choice looks beautiful. @angular2 @expert, What do you think about?
Thx to all, Gabriel
It depends as per your need. Just to be clear Output
and events
are the same. So the flow is quite similar:
Input
Output
which EventEmitter
There is a third option also where you can communicate both ways from child to parent and parent to child or even one component to other. It is using service injection, where your service will have a Subject
and component injecting this service can subscribe or update the subject value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With