Name Angular’s component lifecycle hooks and what each is for.
TechnicalAngular DeveloperSenior full stack developersenior full stack .net and angularAngular has several component lifecycle hooks:
- ngOnInit: Initializes the component after Angular first displays the data-bound properties.
- ngOnChanges: Responds when any data-bound input properties change.
- ngOnDestroy: Cleanup just before Angular destroys the component.
- ngDoCheck: Detects and acts upon changes that Angular can't or won't detect on its own.
- ngAfterViewInit: Called after the component's view has been fully initialized.
These hooks allow for efficient resource management and dynamic updates in the component lifecycle.