The method ______ is called just before Angular destroys the component.
- ngAfterViewInit
- ngOnChanges
- ngOnDestroy
- ngOnInit
The method ngOnDestroy is called just before Angular destroys a component. Developers can use this method to perform cleanup tasks, such as unsubscribing from observables, releasing resources, or canceling ongoing operations, before the component is removed from the DOM. It's a crucial part of component lifecycle management in Angular.
Loading...
Related Quiz
- Which method would you use in HttpInterceptor to catch and handle HTTP errors?
- Imagine you have a modal component, and you want users to define custom header, body, and footer for each modal instance. How would you set up the modal component to achieve this?
- The directive that's used to manipulate the structure of the DOM by adding/removing elements is prefixed with ________.
- A client asks you to highlight the currently active page link in the navigation menu. How would you achieve this in Angular?
- How can you set default headers for every request made by HttpClient in your application?