At which lifecycle hook is it best to make an HTTP request in an Angular component?

  • constructor
  • ngAfterViewInit
  • ngOnDestroy
  • ngOnInit
In Angular, it's best to use the ngOnInit lifecycle hook to handle any additional initialization tasks, including making HTTP requests. The constructor is mainly used for dependency injection and not for logic.
Add your answer
Loading...

Leave a comment

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