Reputation: 3
I've noticed that in Angular, the constructor of a component runs before the ngOnChanges hook, despite the constructor not being considered a part of the lifecycle hooks. Could someone explain why this happens?
I've noticed that in Angular, the constructor of a component runs before the ngOnChanges hook, despite the constructor not being considered a part of the lifecycle hooks. Could someone explain why ?
Upvotes: -1
Views: 182
Reputation: 350
If you think about it, you won't even have a component if you don't call a constructor function. Unless the functions are static, in any language, you need to construct the class's object before using any of it's function. That's why constructor will always be the first function to get called.
Upvotes: 0