Bird
0
0

How do you specify the OnPush change detection strategy in an Angular component decorator?

easy📝 Syntax Q3 of 15
Angular - Change Detection
How do you specify the OnPush change detection strategy in an Angular component decorator?
A@Component({ changeDetection: 'OnPush' })
B@Component({ changeDetection: ChangeDetectionStrategy.OnPush })
C@Component({ strategy: ChangeDetection.OnPush })
D@Component({ detectChanges: OnPush })
Step-by-Step Solution
Solution:
  1. Step 1: Recall Syntax

    The correct property is 'changeDetection' with value ChangeDetectionStrategy.OnPush.
  2. Step 2: Validate Options

    Only @Component({ changeDetection: ChangeDetectionStrategy.OnPush }) uses the correct property and enum syntax.
  3. Final Answer:

    @Component({ changeDetection: ChangeDetectionStrategy.OnPush }) -> Option B
  4. Quick Check:

    Use 'changeDetection' with enum for OnPush [OK]
Quick Trick: Use changeDetection: ChangeDetectionStrategy.OnPush [OK]
Common Mistakes:
MISTAKES
  • Using string 'OnPush' instead of enum
  • Incorrect property names like 'strategy' or 'detectChanges'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes