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.
Loading...
Related Quiz
- In template-driven forms, which directive is used to conditionally apply CSS classes based on control validity?
- The component where the child route should get rendered must contain the ________ directive in its template.
- In an e-commerce application, you want to ensure that product details fetched from the server are not requested again for a certain period. Which technique would be effective for this scenario?
- In a Route Guard, to navigate to a different route due to an authorization failure, you would typically use the router.______ method.
- To make a service available only within a specific module, set the providedIn property to the ________ of that module.