In a large Angular app, you want to optimize performance by reducing unnecessary view updates. You decide to keep the default change detection strategy but want to limit checks on a specific component. Which approach fits best?
AUse <code>ChangeDetectorRef.detach()</code> to stop change detection on that component manually
BSet <code>changeDetection: ChangeDetectionStrategy.Default</code> on that component
CUse <code>markForCheck()</code> to force detection every time
DReplace default strategy with OnPush on all components
Step-by-Step Solution
Solution:
Step 1: Understand default strategy limits
Default strategy runs change detection frequently, which can be costly in large apps.
Step 2: Identify how to limit detection on one component
Using ChangeDetectorRef.detach() stops change detection on that component until manually reattached.
Step 3: Evaluate other options
Setting default again does nothing new; markForCheck forces detection; OnPush changes strategy globally, not selectively.
Final Answer:
Use ChangeDetectorRef.detach() to stop change detection on that component manually -> Option A
Quick Check:
Detach stops detection selectively [OK]
Quick Trick:Detach change detector to pause updates on specific component [OK]
Common Mistakes:
MISTAKES
Thinking setting default again limits detection
Confusing markForCheck with stopping detection
Assuming OnPush is selective per component
Master "Change Detection" in Angular
9 interactive learning modes - each teaches the same concept differently