Lifecycle hooks in angular are callback functions that angular calls when some events take place during the component's life cycle. Let’s understand this concept with some examples-

  • ngOnDestroy- This lifecycle hook is called by the angular when a component is destroyed.
  • ngOnChanges- When a component’s input property changes, angular invokes ngOnChanges.
  • ngOnInit- This lifecycle hook is called when a component is initialized for the first time by angular.
BY Best Interview Question ON 22 Sep 2021