Difference between Constructor and ngOnInit

Difference between Constructor and ngOnInit.

The main difference between constructor and ngOnInit is that ngOnInit is lifecycle hook and runs after constructor. Component interpolated template and input initial values aren’t available in constructor, but they are available in ngOnInit. The practical difference is how ngOnInit affects how the code is structured.