Angular Lifecycle Hooks

📘 Angular 👁 110 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

🤖 AI Quizer Assistant

📝 Quiz
📚 Categories
🏆 Leaderboard
📊 My Score
❓ Help
👋 Hi! I'm your AI quiz assistant for Quizer.in!

I can help you with:
• 📝 Finding quizzes
• 🏆 Checking leaderboard
• 📊 Your performance stats

Type 'help' to get started! 🚀
AI is thinking...