Medium
What is the difference between ngOnInit()
and constructor()
in Angular?
Author: abdelghaniStatus: PublishedQuestion passed 361 times
Edit
2
Community Evaluations
Victor SILVESTRE
11/08/2024
Je ne comprend pas : la première réponse "le constructeur est appelé avant le lifecycle hook ngOnInit" est vrai.
En effet, le constructeur n'a pas besoin d'attendre l'initialisation des propriétés du component.
"From a chronological standpoint, the constructor is called first. Then, once all component inputs are initialized, Angular is going to call ngOnInit." --Alain Chautard expert Angular at Google
Je me trompe ?
Similar QuestionsMore questions about Angular
14
What is TypeScript?8
Specify the location in the DOM where the component of the active route will be inserted in Angular6
How to capitalize the first letter of each word in a string in Angular5
Which flag allows you to specify, when creating an application, that you want to use SCSS for styles?5
What is Angular?