The idea behind using a setter is that whenever the @Input changes, it is setting a new value for this.message, which ends up triggering the setter and the extra code in it to notify of the update.

The getter is not used in that basic example but it’s very likely that a real-life component would need it to display that value in its template for instance.

--

Google Developer Expert in Angular, Consultant and Trainer at http://www.angulartraining.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store