What is the difference between Constructor and ngOnInit in Angular?

0 votes
386 views
asked Jan 18 by Hitesh Garg (352 points)  

When we use the angular cli to generate a new component there is a hook for ngOnInit by default. Since we already have a constructor in the class why do we need this ngOnInit hook?

Please log in or register to answer this question.

Welcome to Codingeek Q&A, where you can ask questions and receive answers from other members of the community.
...