ngOnInit and Initialization
Run setup logic when a component starts.
What Are Lifecycle Hooks?
Angular components have a lifecycle managed by the framework: creation, change detection, rendering, and destruction. Lifecycle hooks let you run code at specific moments.
Introducing OnInit
The OnInit hook runs once, after Angular has set the component inputs and rendered the initial view. It is the standard place for initialization logic.
All lessons in this course
- ngOnInit and Initialization
- ngOnChanges and Input Changes
- ngOnDestroy and Cleanup
- AfterView and AfterContent Hooks