What is the difference between markForCheck and detectChanges?

Angular signals and change detection · Experienced

Model answer

markForCheck marks the component and its parents as needing a check and lets Angular's normal change detection run it soon. It is the safe choice with OnPush when data changed from outside Angular's view of things. detectChanges runs change detection for that component and its children immediately, which is more direct and can be costly or cause errors if called too often or during a check.

Prefer signals and the async pipe so that you rarely need either. If you must choose, use markForCheck.

Learn this topic

Angular Tutorial: Beginner to Advanced .

Sign in to add your own answer.

More questions