Communicating with other components
In a nutshell, Angular components expose a public API that allows them to communicate with other components. This API encompasses input properties, which we use to feed the component with data. It also exposes output properties we can bind event listeners to, thereby getting timely information about changes in the state of the component.
Let's take a look at how Angular solves the problem of injecting data into and removing data from components through quick and easy examples in the following sections.
Passing data using input binding
In the Creating our first component section, we learned how to create a new component in an Angular project. The Angular CLI created a template with static HTML content for our new component by default:
<p>hero works!</p>
To see the new component in action, do the following:
- Navigate to the
app
folder that exists inside thesrc
folder. - Open the template of the main component...