Medium
What is the difference between ngOnInit()
and constructor()
in Angular?
Author: abdelghaniStatus: PublishedQuestion passed 284 times
Edit
1
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
12
What is TypeScript?7
Specify the location in the DOM where the component of the active route will be inserted in Angular5
How to capitalize the first letter of each word in a string in Angular4
Which flag allows you to specify, when creating an application, that you want to use SCSS for styles?3
What is Angular?