Explain lifecycle hooks in Angular, and when would you use each?
TechnicalAngular DeveloperFrontend DeveloperWeb DeveloperAngular lifecycle hooks are methods that allow us to tap into key moments in a component's lifecycle. The main hooks include ngOnInit, which is used for initialization logic after the component is constructed, and ngOnChanges, which reacts to input property changes.
We use ngOnDestroy to clean up resources, like unsubscribing from observables, preventing memory leaks. Each hook serves a specific purpose, helping manage the component's state and performance effectively.