Bird
0
0

You want to optimize a large Angular app by changing some components to OnPush strategy. What is a key difference you must handle compared to the default strategy?

hard🧠 Conceptual Q8 of 15
Angular - Change Detection
You want to optimize a large Angular app by changing some components to OnPush strategy. What is a key difference you must handle compared to the default strategy?
AOnPush requires manual calls to detectChanges() always
BOnPush runs change detection on every event like the default strategy
COnPush disables change detection completely
DOnPush only runs change detection when input references change or events occur inside the component
Step-by-Step Solution
Solution:
  1. Step 1: Understand OnPush behavior

    OnPush strategy runs change detection only when input property references change or events happen inside the component.
  2. Step 2: Compare with default strategy

    Default runs on every event globally, OnPush is more selective, improving performance but requiring careful input management.
  3. Final Answer:

    OnPush only runs change detection when input references change or events occur inside the component -> Option D
  4. Quick Check:

    OnPush triggers on input ref changes or internal events [OK]
Quick Trick: OnPush triggers only on input ref changes or internal events [OK]
Common Mistakes:
MISTAKES
  • Thinking OnPush runs on every event
  • Assuming OnPush disables detection
  • Believing manual detectChanges() always needed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes