CodeZettaInterview Hub

Angular · Change Detection · Junior · Comparison

What does markForCheck vs detectChanges do?

Short Interview Answer

markForCheck marks the path to root dirty for the next CD; detectChanges runs CD immediately on that view.

Detailed Explanation

Use markForCheck inside OnPush when updating state outside Angular's knowledge. detectChanges is sharper and can be used carefully in tests/directives.

Did you know this answer?