You are on page 1of 1

27/09/2022, 21:06 Angular - The Complete Guide (2022 Edition) | Udemy

Angular - The Complete Guide (2022 Edition) Share

Course content Overview Q&A Notes Announcements Reviews Learning tools

Back to All Questions

Using ngOnChanges hook instead of set method 0


PV
Paradigm Compass · Lecture 101 · 4 years ago

So, if I understood correctly the set method will be invoked whenever the property changes. This is somehow similar
to the lifecycle hook OnChanges, so I was wondering if technically is there any advantage to use the set approach
when we just want to listen for changes on a property (and we don't care about previous value and other information
provided by the hook).

1 reply Follow replies

Maximilian — Instructor 9
4 years ago

Hi Vanio,

It's actually not really comparable.


set is indeed invoked whenever the value changes but set can be used on ANY property. onChanges only fires
if a property marked with @Input() changes (i.e. when your bindable properties change).

Max

JS Add reply

Teach the world online


https://www.udemy.com/course/the-complete-guide-to-angular-2/learn/lecture/6656186#questions/3215168 1/2

You might also like