Bird
0
0

What is the main reason to use ChangeDetectionStrategy.OnPush in an Angular component?

easy🧠 Conceptual Q11 of 15
Angular - Change Detection
What is the main reason to use ChangeDetectionStrategy.OnPush in an Angular component?
ATo improve performance by checking for changes only when inputs change or events occur
BTo disable change detection completely
CTo force Angular to check for changes on every event
DTo automatically update the component without any input changes
Step-by-Step Solution
Solution:
  1. Step 1: Understand OnPush behavior

    OnPush tells Angular to check for changes only when input properties change or events inside the component happen.
  2. Step 2: Compare with other options

    It does not disable change detection or force checks on every event, but optimizes performance by limiting checks.
  3. Final Answer:

    To improve performance by checking for changes only when inputs change or events occur -> Option A
  4. Quick Check:

    OnPush improves performance = A [OK]
Quick Trick: OnPush triggers checks only on input or event changes [OK]
Common Mistakes:
MISTAKES
  • Thinking OnPush disables change detection
  • Assuming OnPush checks on every event
  • Believing OnPush updates without input changes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes