Angular - Change DetectionHow can you ensure a deeply nested object input triggers change detection in an OnPush component?ACreate a new object reference when updating nested properties.BModify nested properties directly without changing the object.CUse <code>ChangeDetectorRef.detach()</code> to force detection.DSet the component's change detection to default.Check Answer
Step-by-Step SolutionSolution:Step 1: Recognize OnPush input detectionOnPush detects changes by comparing input references, not deep properties.Step 2: Update nested objects correctlyCreating a new object reference triggers detection; direct mutation does not.Final Answer:Create a new object reference when updating nested properties. -> Option AQuick Check:Trigger OnPush with new object reference [OK]Quick Trick: Always replace objects to trigger OnPush detection [OK]Common Mistakes:MISTAKESMutating nested properties directlyUsing detach() incorrectlySwitching to default detection unnecessarily
Master "Change Detection" in Angular9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More Angular Quizzes Angular Change Detection - Default change detection strategy - Quiz 8hard HTTP Client - Handling HTTP errors - Quiz 15hard HTTP Client - Loading states and error patterns - Quiz 11easy Routing - RouterLink for navigation - Quiz 15hard Routing - Query parameters and fragments - Quiz 7medium RxJS Operators - combineLatest and forkJoin for combining - Quiz 4medium RxJS Operators - map operator for transformation - Quiz 9hard Services and Dependency Injection - Singleton service behavior - Quiz 5medium Services and Dependency Injection - How dependency injection works in Angular - Quiz 6medium Template-Driven Forms - Two-way binding in forms - Quiz 6medium