Bird
0
0

Given a component with OnPush strategy, what triggers change detection for it?

medium🧠 Conceptual Q4 of 15
Angular - Change Detection
Given a component with OnPush strategy, what triggers change detection for it?
AAny event in the app triggers it
BOnly when a service updates data
COnly when @Input properties change or an event inside the component
DChange detection never runs automatically
Step-by-Step Solution
Solution:
  1. Step 1: Understand OnPush triggers

    OnPush runs change detection only when inputs change or events inside the component occur.
  2. Step 2: Eliminate incorrect triggers

    It does not run on any app event or only service updates; it runs automatically on input changes or internal events.
  3. Final Answer:

    Only when @Input properties change or an event inside the component -> Option C
  4. Quick Check:

    OnPush triggers = Input changes or internal events [OK]
Quick Trick: OnPush triggers on input changes or internal events [OK]
Common Mistakes:
MISTAKES
  • Assuming all app events trigger OnPush
  • Thinking service updates always trigger it
  • Believing it never runs automatically

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes