The initial phase of the component is confirmed by Angular, and Angular then offers a component view and viewpoint of its child component, starting the life cycle of the Angular model. When a feature associated with the data changes, Angular checks to see if it has changed. It then updates the view and partial events as necessary, continuing the life cycle. When Angular dismisses a component event and removes its supplied template from the DOM, the life cycle is complete. The life cycle of guides is the same as that of events since Angular produces, changes, and destroys events as it runs.
Your app can respond to updates during discovery, begin new situations, initiate change as needed, and clean up before removal using life cycle tactics to enter significant events in the partial life cycle.
Understanding the function of angular lifecycle hooks.
1. Recognize the many phases that the angular portion goes through from production to annihilation.
2. Utilize your code and be aware of how to enter those categories.
3. Be aware of the progression of events and the factors that lead to each stage.
Several stages of a component.
Hooks are manufactured as follows:-
1. constructor
2. ngOnchanges
3. ngOnint
4. ngDoCheck
5. ngAfterContentinit
6. ngAfterContentChecked
7. ngAfterViewinit
8. ngAfterViewChecked
9. ngOnDestroy
THE ANGULAR COMPONENT HOOKS:
constructor:-
When Angular creates a section or instructions for calling new ones to the class, this is required.
ngonchanges:-
If one component feature changes, it is always requested.
ngOnint:-
When provided, the requested segment has already begun. After the initial OnChanges, just one call to this hook is made.
ngDoCheck :-
while utilising a substitute partitioner, requested. It enables us to utilise our method to find modifications to a specific component.
ngAfterContentinit:-
Angular will utilise this function shortly before it kills the part. To prevent memory leaks, use this hook to remove yourself from the list of objects and to delete event holders.
ngAfterContentChecked:-
Every time the content of a specific component is assessed to determine the Angular transition mechanism, a request is made.
ngafterViewinit :-
When partial viewing is completely functional, this is requested.
ngAfterViewChecked:-
Every time a view of a certain component is tested, a request is made to find the Angular transition function.
ngOnDestroy :-
Just before Angular removes a discipline or component, cleaning. In order to stop memory leaks, unsubscribe from and remove event holders.