Angular Architecture & Modules Quiz – 20 Questions with Answers
20 questions · 15 min · Medium
Test your knowledge of Angular lifecycle hooks, including ngOnInit, ngOnChanges, ngDoCheck, ngAfterContentInit, ngAfterContentChecked, ngAfterViewInit, ngAfterViewChecked, and ngOnDestroy.
No sign-up needed · Last updated:
Score: 0 00:00
Create a free account to keep your scores and track your progress. It is optional.
20 questions · 15 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
A. Methods that allow a component to respond to important moments in its lifecycle
Angular lifecycle hooks let components and directives run code at specific stages of their creation, change detection, rendering, and destruction.
A. ngOnInit
ngOnInit runs once after Angular has initialized the component's input properties.
A. ngOnChanges
ngOnChanges runs when Angular detects changes to data-bound input properties and receives a SimpleChanges object describing those changes.
A. SimpleChanges
ngOnChanges receives a SimpleChanges object containing information about the current and previous values of changed input properties.
A. ngDoCheck
ngDoCheck runs during Angular's change-detection process and can be used when custom change detection logic is required.
A. ngAfterContentInit
ngAfterContentInit runs once after Angular has completed initialization of the component's projected content.
A. ngAfterContentChecked
ngAfterContentChecked runs after Angular checks the content projected into the component.
A. ngAfterViewInit
ngAfterViewInit runs once after Angular has fully initialized the component's view and its child views.
A. ngAfterViewChecked
ngAfterViewChecked runs after Angular has completed a check of the component's view and child views.
A. ngOnDestroy
ngOnDestroy runs immediately before Angular destroys a component or directive and is commonly used for cleanup.
A. Cleaning up subscriptions or event listeners
ngOnDestroy is commonly used to release resources such as subscriptions, timers, or event listeners before a component is destroyed.
A. Once
ngOnInit runs once after Angular has initialized the component's input properties.
A. ngAfterViewInit
ngAfterViewInit runs after the component's view and child views have been initialized, making it useful for view-related initialization.
A. ngAfterViewChecked
ngAfterViewChecked can run repeatedly whenever Angular performs checks on the component's view.
A. Initialization, change detection, view/content checks, and destruction
Angular components move through stages that include initialization, change detection and view/content checks, followed eventually by destruction.