Question · Angular course · Module 2: Components

ngOnInit

Which lifecycle hook is ideal for fetching data from an API when the component initializes?

Answer options

  • constructor
  • ngOnInit
  • ngAfterViewInit
  • ngOnDestroy
Show the answer

Correct answer:

  • ngOnInit