Angular Lifecycle Hooks

📘 Angular 👁 69 views 📅 Nov 14, 2025
⏱ Estimated reading time: 1 min

Angular Lifecycle Hooks

Angular components go through a series of lifecycle stages from creation to destruction. Lifecycle hooks allow developers to tap into these stages and perform actions.

Common Lifecycle Hooks

  • ngOnInit() – Called once the component is initialized.
  • ngOnChanges() – Called when input properties change.
  • ngDoCheck() – Custom change detection.
  • ngAfterViewInit() – After component view is initialized.
  • ngOnDestroy() – Cleanup code before component is destroyed.

Example

export class ExampleComponent implements OnInit, OnDestroy {

  ngOnInit() {
    console.log('Component Initialized');
  }

  ngOnDestroy() {
    console.log('Component Destroyed');
  }
}

🔒 Some advanced sections are available for Registered Members
Register Now

Share this Post


← Back to Tutorials

Popular Competitive Exam Quizzes