Skip to main content

Posts

Showing posts with the label What is the life-cycle of an Angular 17 component?

Angular 17 Component Lifecycle Hooks | Angular Lifecycle Hooks: A Complete Guide

What is the life cycle of an Angular 17 component? A component's lifecycle is the sequence of steps that happen between the component's creation and its destruction. Each step represents a different part of Angular's process for rendering components and checking them for updates over time. 4 Phases are: Phase 1 - Creation : Constructor : - Standard JavaScript class constructor. Runs when Angular instantiates the component.   Phase 2 - Change Detection:  ngOnInit: - Runs once after Angular has initialized all the component's inputs. Phase 3 - Rendering: - ngOnChanges :- Runs every time the component's inputs have changed. ngDoCheck :- Runs every time this component is checked for changes. ngAfterViewInit :- Runs once after the component's view has been initialized. ngAfterContentInit :- Runs once after the component's content has been initialized. ngAfterViewChecked :- Runs every time the component's view has been checked for chang...