Using setters for intercepting input property changes
In this recipe, you will learn about how to intercept changes in an @Input
passed from a parent component and to perform some action on this event. We'll intercept the vName
input passed from the VersionControlComponent
parent component to the VcLogsComponent
child component. We'll use setters to generate a log whenever the value of vName
changes and will show those logs in the child component.
Getting ready
The project for this recipe resides in chapter01.start_here/cc-setters
:
- Open the project in Visual Studio Code.
- Open the terminal and run
npm install
to install the dependencies of the project. - Once done, run
ng serve -o
. This should open the app in a new browser tab and you should see the app as follows:
How to do it…
- We'll first create a logs array in
VcLogsComponent
as...