Which lifecycle hook is called once when the component is initialized?
- ngAfterViewInit
- ngOnChanges
- ngOnDestroy
- ngOnInit
The ngOnInit lifecycle hook is called once when the component is initialized. It's a common place to put initialization logic for a component. ngOnChanges is called when input properties change, ngOnDestroy is called when the component is about to be destroyed, and ngAfterViewInit is called after the view has been initialized.
Loading...
Related Quiz
- The * syntax in directives like *ngIf and *ngFor is a syntactic sugar for using ________.
- What's a key difference between Just-in-Time (JIT) and Ahead-of-Time (AOT) Compilation in Angular?
- When setting up routes in an Angular application, which property in the route configuration determines the component that should be displayed?
- You have a component that receives a large list of items as an input. You notice performance degradation when items within this list are updated frequently. Which change detection strategy would be most appropriate to address this?
-
When using content projection with
, the projected content's change detection is the responsibility of the ________ component.