Bird
0
0

Why might an Angular developer choose ChangeDetectionStrategy.OnPush for a component?

easy🧠 Conceptual Q1 of 15
Angular - Change Detection
Why might an Angular developer choose ChangeDetectionStrategy.OnPush for a component?
ATo force change detection on every event
BTo enable automatic two-way data binding
CTo disable change detection entirely
DTo improve performance by limiting change detection to specific triggers
Step-by-Step Solution
Solution:
  1. Step 1: Understand OnPush behavior

    OnPush strategy tells Angular to check the component only when its inputs change or an event occurs inside it.
  2. Step 2: Identify benefit

    This reduces unnecessary checks and improves performance, especially in large apps.
  3. Final Answer:

    To improve performance by limiting change detection to specific triggers -> Option D
  4. Quick Check:

    OnPush optimizes change detection cycles [OK]
Quick Trick: OnPush limits checks to input changes and events [OK]
Common Mistakes:
MISTAKES
  • Thinking OnPush disables change detection
  • Assuming OnPush enables automatic two-way binding
  • Believing OnPush forces detection on every event

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes