What is the difference between a constructor and ngOnInit() in Angular. How they called and explain the flow in detail.
What is the difference between a constructor and ngOnInit() in Angular
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Ganesan CRank #369 · 6.8K reputationPosted Aug 11, 2021, 12:56 AM EDT
Ronika JencyRank #770 · 3K reputationPosted Aug 10, 2021, 11:26 PM EDT
Hi,
export class AppName implements OnInit { constructor() { // Called first time before the ngOnInit() } ngOnInit() { // Called after the constructor and called after the first ngOnChanges() } }Please refer below link,
https://www.c-sharpcorner.com/interview-question/what-is-the-difference-between-quotconstructorquot-and-quotngoninitquot-in-angular