Bird
0
0

Which lifecycle hook is called immediately after Angular has initialized all data-bound properties of a component?

easy📝 Conceptual Q1 of 15
Angular - Lifecycle Hooks
Which lifecycle hook is called immediately after Angular has initialized all data-bound properties of a component?
AngDoCheck
BngOnInit
CngOnChanges
DngAfterViewInit
Step-by-Step Solution
Solution:
  1. Step 1: Understand the purpose of ngOnInit

    ngOnInit runs once after Angular sets all input properties, perfect for initialization.
  2. Step 2: Compare with other hooks

    ngOnChanges runs before ngOnInit if inputs change; ngAfterViewInit runs after the view is initialized; ngDoCheck runs during change detection.
  3. Final Answer:

    ngOnInit -> Option B
  4. Quick Check:

    Initialization hook = ngOnInit [OK]
Quick Trick: Initialization after inputs = ngOnInit [OK]
Common Mistakes:
  • Confusing ngOnChanges with ngOnInit
  • Thinking ngAfterViewInit runs first
  • Assuming ngDoCheck is for initialization

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes