The eight essential Angular lifecycle hooks
ngOnChanges
ngOnInit
ngDoCheck
ngAfterContentInit
ngAfterContentChecked
ngAfterViewInit
ngAfterViewChecked
ngOnDestroy
Every time an input property is changed, this hook is triggered.
The ngOnInit lifecycle hook, called after the constructor, is the recommended place for initializing your component.
This hook runs constantly, during every change detection cycle, allowing for custom logic to detect changes.
After the component's content has been initialized, this lifecycle hook is executed. Any setup not yet completed for the component's content can be performed here.
This hook comes after the component's content has been checked, at which point you can do more operations on it.
This hook fires when the component's view is ready, allowing you to interact with the view elements in your code.
After the component's view has been checked, this lifecycle hook is executed, and is where further actions related to the component's view should be performed.
The ngOnDestroy lifecycle hook fires just before the component is destroyed. It’s where you can clean up the component.