Angular - Change DetectionWhich syntax correctly sets the change detection strategy to OnPush in an Angular component?A@Component({ detectionStrategy: OnPush })B@Component({ changeDetection: ChangeDetectionStrategy.Default })C@Component({ changeDetection: ChangeDetectionStrategy.OnPush })D@Component({ changeDetectionStrategy: 'OnPush' })Check Answer
Step-by-Step SolutionSolution:Step 1: Recall correct property nameThe property to set change detection is 'changeDetection' inside @Component decorator.Step 2: Use correct enum valueThe enum value for OnPush is ChangeDetectionStrategy.OnPush, not a string or other property name.Final Answer:@Component({ changeDetection: ChangeDetectionStrategy.OnPush }) -> Option CQuick Check:Use changeDetection with ChangeDetectionStrategy.OnPush [OK]Quick Trick: Use changeDetection: ChangeDetectionStrategy.OnPush exactly [OK]Common Mistakes:MISTAKESUsing wrong property name like detectionStrategyPassing 'OnPush' as stringConfusing Default with OnPush
Master "Change Detection" in Angular9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More Angular Quizzes Angular Change Detection - Zone.js and automatic detection - Quiz 1easy Angular Change Detection - When to use OnPush - Quiz 5medium HTTP Client - Setting headers and params - Quiz 12easy Reactive Forms - Custom validators - Quiz 7medium Routing - Query parameters and fragments - Quiz 3easy RxJS Operators - debounceTime for input throttling - Quiz 6medium RxJS and Observables Fundamentals - Why observables matter in Angular - Quiz 5medium Services and Dependency Injection - Service-to-service injection - Quiz 7medium Services and Dependency Injection - How dependency injection works in Angular - Quiz 11easy Template-Driven Forms - Form validation with template attributes - Quiz 13medium