Bird
0
0

You want to optimize an Angular app by running change detection only when needed. Which strategy helps achieve this?

hard🧠 Conceptual Q8 of 15
Angular - Change Detection
You want to optimize an Angular app by running change detection only when needed. Which strategy helps achieve this?
ADisable change detection globally
BUse OnPush change detection strategy and immutable data
CCall detectChanges() in every lifecycle hook
DReload the page after every data change
Step-by-Step Solution
Solution:
  1. Step 1: Understand OnPush strategy

    OnPush runs change detection only when input references change, improving performance.
  2. Step 2: Combine with immutable data

    Immutable data ensures changes are detected by reference checks.
  3. Final Answer:

    Use OnPush change detection strategy and immutable data -> Option B
  4. Quick Check:

    OnPush + immutable data = optimized detection [OK]
Quick Trick: OnPush with immutable data reduces unnecessary checks [OK]
Common Mistakes:
MISTAKES
  • Disabling detection globally breaks UI updates
  • Calling detectChanges() everywhere hurts performance
  • Reloading page is inefficient and disruptive

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes