What are the lifecycle hooks event in Angular?
When the angular application runs, it goes through a different life cycle. Following are the life cycle hooks that angular goes through
After the first ngOnChanges.
When the change detection is performed, ngDoCheck() is called to perform your custom change detection.
Just before the directive is destroyed.
The Constructor
is a default method of the class that is executed when the class is instantiated and ensures proper initialisation of fields in the class and its subclasses while ngOnInit is angular life cycle hook method.
When component input/output binding value chages
- ngAfterContentInit (only for components)
After component content initialized.
- ngAfterContentChecked (only for components)
After every check of component content.
- ngAfterViewInit (only for components)
After a component’s views are initialized.
- ngAfterViewChecked (only for components)
After every check of a component’s views.