+1 vote
in Angular by

What are lifecycle hooks available?

1 Answer

0 votes
by

Angular application goes through an entire set of processes or has a lifecycle right from its initiation to the end of the application. The representation of lifecycle in pictorial representation as follows,

  1. The description of each lifecycle method is as below,
  2. ngOnChanges: When the value of a data bound property changes, then this method is called.
  3. ngOnInit: This is called whenever the initialization of the directive/component after Angular first displays the data-bound properties happens.
  4. ngDoCheck: This is for the detection and to act on changes that Angular can't or won't detect on its own.
  5. ngAfterContentInit: This is called in response after Angular projects external content into the component's view.
  6. ngAfterContentChecked: This is called in response after Angular checks the content projected into the component.
  7. ngAfterViewInit: This is called in response after Angular initializes the component's views and child views.
  8. ngAfterViewChecked: This is called in response after Angular checks the component's views and child views.
  9. ngOnDestroy: This is the cleanup phase just before Angular destroys the directive/component.

...