Angular - Change DetectionYou want to optimize an Angular app by running change detection only when needed. Which strategy helps achieve this?ADisable change detection globallyBUse OnPush change detection strategy and immutable dataCCall detectChanges() in every lifecycle hookDReload the page after every data changeCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand OnPush strategyOnPush runs change detection only when input references change, improving performance.Step 2: Combine with immutable dataImmutable data ensures changes are detected by reference checks.Final Answer:Use OnPush change detection strategy and immutable data -> Option BQuick Check:OnPush + immutable data = optimized detection [OK]Quick Trick: OnPush with immutable data reduces unnecessary checks [OK]Common Mistakes:MISTAKESDisabling detection globally breaks UI updatesCalling detectChanges() everywhere hurts performanceReloading page is inefficient and disruptive
Master "Change Detection" in Angular9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More Angular Quizzes Angular Change Detection - When to use OnPush - Quiz 1easy HTTP Client - HttpClientModule setup - Quiz 1easy Reactive Forms - Validators (required, minLength, pattern) - Quiz 12easy Routing - RouterModule configuration - Quiz 6medium Routing - Route guards (canActivate, canDeactivate) - Quiz 4medium Services and Dependency Injection - How dependency injection works in Angular - Quiz 1easy Template-Driven Forms - ngForm directive and form state - Quiz 2easy Template-Driven Forms - ngModel for form binding - Quiz 9hard Template-Driven Forms - Form validation with template attributes - Quiz 4medium Template-Driven Forms - Form submission handling - Quiz 15hard