Bird
0
0

Why might ngOnChanges not be called even though an input property value appears to have changed?

hard📝 Conceptual Q10 of 15
Angular - Lifecycle Hooks
Why might ngOnChanges not be called even though an input property value appears to have changed?
ABecause <code>ngOnChanges</code> only runs once per component lifecycle
BBecause the input value changed internally but its reference stayed the same
CBecause the input property is not decorated with <code>@Input()</code>
DBecause the component does not implement <code>OnInit</code>
Step-by-Step Solution
Solution:
  1. Step 1: Recall how Angular detects input changes

    Angular uses reference checks, so internal mutations without reference change do not trigger ngOnChanges.

  2. Step 2: Understand other options

    ngOnChanges runs multiple times, @Input is required but assumed here, and OnInit is unrelated.

  3. Final Answer:

    Because the input value changed internally but its reference stayed the same -> Option B
  4. Quick Check:

    Reference change triggers ngOnChanges [OK]
Quick Trick: Input reference must change to trigger ngOnChanges [OK]
Common Mistakes:
  • Thinking ngOnChanges runs only once
  • Ignoring the need for @Input decorator
  • Confusing OnInit with OnChanges

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes