You're building a carousel component that requires initialization logic after its views are rendered. Which lifecycle hook would be most appropriate for this?

  • ngOnInit
  • ngAfterViewInit
  • ngOnChanges
  • ngOnDestroy
In Angular, the ngAfterViewInit lifecycle hook is most appropriate when you need to perform initialization logic after a component's views have been rendered. This hook is called once when the component's view and its children's views are initialized. ngOnInit is called earlier, before child views are ready, and the other options are not typically used for initialization logic in this context.
Add your answer
Loading...

Leave a comment

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