© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2024
M. D. CallaghanAngular for Business https://doi.org/10.1007/978-1-4842-9609-7_12

12. Best Practices for Handling Changes to Input Properties in Angular

Michael D. Callaghan1  
(1)
Celebration, FL, USA
 

The Pros and Cons of Property Setters vs. ngOnChanges

As Angular developers, one of the challenges we often face is how to handle changes to input properties in our components. There are a few different approaches we can take, and in this chapter, we’ll take a look at the pros and cons of using property setters versus the ngOnChanges lifecycle hook. We’ll also provide some guidelines for deciding which approach is best for your project.

A recent tweet about @Input() ...

Get Angular for Business: Awaken the Advocate Within and Become the Angular Expert at Work 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.