Bird
0
0

You want to optimize performance by running a heavy calculation without triggering Angular change detection until it finishes. Which approach is best?

hard🚀 Application Q8 of 15
Angular - Change Detection
You want to optimize performance by running a heavy calculation without triggering Angular change detection until it finishes. Which approach is best?
ARun the calculation inside runOutsideAngular, then update UI inside run() after completion
BRun the calculation inside run() to keep Angular aware
CRun the calculation outside Angular and never update UI
DRun the calculation inside a setTimeout without zones
Step-by-Step Solution
Solution:
  1. Step 1: Understand performance optimization with zones

    Heavy calculations outside Angular zone avoid unnecessary change detection cycles.
  2. Step 2: Update UI after calculation

    After calculation, re-enter Angular zone with run() to update UI safely.
  3. Final Answer:

    Run the calculation inside runOutsideAngular, then update UI inside run() after completion -> Option A
  4. Quick Check:

    Heavy work outside zone + UI update inside zone = Run the calculation inside runOutsideAngular, then update UI inside run() after completion [OK]
Quick Trick: Heavy work outside zone, UI update inside zone [OK]
Common Mistakes:
MISTAKES
  • Running heavy work inside Angular zone causing slow UI
  • Not updating UI after calculation
  • Ignoring zone boundaries

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes