How to do inter communication between a master and detail component in Angular2?

Here’s a simple app that uses a parent <customer-browser> component with <customer-list> and <customer-detail> subcomponents.

http://plnkr.co/edit/aEjlwIKKhcErWAnIhY3C?p=preview

The browser itself simply accepts an array of customers as an input, and has an internal selectedCustomer property.

The list component accepts the same list, and exposes a “selected” property, and emits a selectedChange output event. This syntax allows two way binding, and that gets bound to the parent’s selectedCustomer property.

The detail component simply takes an customer input which is bound to the parent’s selectedCustomer property.

Leave a Comment