Bird
0
0

What does the ngOnChanges lifecycle hook detect in an Angular component?

easy📝 Conceptual Q1 of 15
Angular - Lifecycle Hooks
What does the ngOnChanges lifecycle hook detect in an Angular component?
AChanges to the component's CSS styles
BChanges to component's internal variables
CChanges to input properties passed from a parent component
DChanges to the component's template HTML
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of ngOnChanges

    This hook is called when Angular sets or resets data-bound input properties.

  2. Step 2: Identify what triggers ngOnChanges

    It triggers only when input properties from the parent change, not internal variables or template changes.

  3. Final Answer:

    Changes to input properties passed from a parent component -> Option C
  4. Quick Check:

    ngOnChanges detects input changes [OK]
Quick Trick: ngOnChanges runs only on input property changes [OK]
Common Mistakes:
  • Thinking it detects internal variable changes
  • Confusing it with template or style changes
  • Assuming it runs on every component update

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes