Skip to main content

Explain Angular Lifecycle Hooks.

Entry Angular
Quick Answer Lifecycle hooks let you run code at specific phases of a component's life. Key hooks: ngOnInit (after inputs are set - good for data fetching), ngOnChanges (when input properties change), ngOnDestroy (cleanup - unsubscribe observables, clear timers), ngAfterViewInit (after view and child views are initialized). Implement the corresponding interface (OnInit, OnDestroy etc.).

Answer

Lifecycle hooks allow running code at specific moments such as initialization, change detection, and destruction.

Important hooks include ngOnInit, ngOnDestroy, and ngOnChanges.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice