What are the difference between constructor and ngOnInit in Angular 6?
S.no | Constructor | ngOnInit |
---|---|---|
1. | The Constructor is a default method of the class executed when the class is instantiated and makes sure proper field initialization in the classes and subclasses. | In Angular 6, ngOnInit is a life cycle hook used to by the program to indicate that the component is successfully created by the Angular. |
BY Best Interview Question ON 14 Dec 2019