Question from the Angular - Fundamentals test

Explain the purpose of the ngOnInit() lifecycle hook in Angular.

Medium

What is the difference between ngOnInit() and constructor() in Angular?

Author: abdelghaniStatus: PublishedQuestion passed 325 times
Edit
1
Community Evaluations
developer avatar
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 ?
developer avatar
Auteur anonyme
23/08/2024
Oui la question a l'air ambigüe. Tu peux proposer une modification ou une nouvelle question