Angular · Junior · Question 34 of 75

What is ngOnInit typically used for?

Explanation

Inputs are already set when ngOnInit runs, but not yet in the constructor. The constructor is for injecting dependencies; heavier work belongs in ngOnInit.

Further reading

Problem with a question

Angular · Junior · question 34

Test yourself

Take the Angular · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz