You are building a component that fetches data from an API. However, you want to ensure that the component only triggers the API call when it's actually visible to the user. Which lifecycle hook can help you achieve this?

  • ngAfterViewInit Lifecycle Hook
  • ngDoCheck Lifecycle Hook
  • ngOnDestroy Lifecycle Hook
  • ngOnInit Lifecycle Hook
To ensure that the component triggers the API call when it's actually visible, you can use the ngAfterViewInit lifecycle hook, which is called after the component's view has been initialized.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *