Google News
logo
Angular - Interview Questions
What is the main difference between constructor and ngOnInit ?
The constructor is a feature of the class itself, not Angular. The main difference is that Angular will launch ngOnInit after it has finished configuring the component. Meaning, it is a signal through which the @Input() and other banding properties and decorated properties are available in ngOnInit, but are not defined within the constructor by design.
Advertisement