Angular - Change DetectionHow 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 })Check Answer
Step-by-Step SolutionSolution:Step 1: Recall SyntaxThe correct property is 'changeDetection' with value ChangeDetectionStrategy.OnPush.Step 2: Validate OptionsOnly @Component({ changeDetection: ChangeDetectionStrategy.OnPush }) uses the correct property and enum syntax.Final Answer:@Component({ changeDetection: ChangeDetectionStrategy.OnPush }) -> Option BQuick Check:Use 'changeDetection' with enum for OnPush [OK]Quick Trick: Use changeDetection: ChangeDetectionStrategy.OnPush [OK]Common Mistakes:MISTAKESUsing string 'OnPush' instead of enumIncorrect property names like 'strategy' or 'detectChanges'
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