Jul 30, 2017 · 1 min read
Can you please explain when to use markForCheck and when detectChanges?
Docs says:
markForCheck(): Marks all ChangeDetectionStrategy ancestors as to be checked.
detectChanges(): Checks the change detector and its children.
Does it means that markForCheck is from the root to the calling component and detectChanges is from the calling component to all children?
Doesn’t change detection always happens from root even when calling detectChanges?
I saw markForCheck used with OnPush when mutating an object or receiving a change outside of angular zone and detectChanges when we want to trigger a check in a detached component.