Chapter 6. Component Communication

Up until now, we have built a single component, but the real power of Angular components is building the interaction between them. in this chapter, we will learn how components can communicate in different ways:

  • Pass data from the parent component to the child through properties
  • Define custom events on a child component for the parent to listen to
  • Communicate via local variables
  • Query child components using the parent component

Passing data via properties

The parent component can pass data to the child component through properties. There are two ways that define input properties for a component:

  • By creating an input array on the component decorator
  • By using the @Input decorator for decorating a class property

Using the ...

Get Angular 2 Components now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.