0Pricing
Angular Academy · Lesson

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

  1. ngOnInit and Initialization
  2. ngOnChanges and Input Changes
  3. ngOnDestroy and Cleanup
  4. AfterView and AfterContent Hooks
← Back to Angular Academy