Class Overview
class ChangeDetectorRef {
}
Class Description
Class Details
markForCheck() : void
Marks all ChangeDetectionStrategy
ancestors as to be checked.
detach() : void
Detaches the change detector from the change detector tree.
The detached change detector will not be checked until it is reattached.
This can also be used in combination with ChangeDetectorRef
to implement
local change
detection checks.
The following example defines a component with a large list of readonly data. Imagine the data changes constantly, many times per second. For performance reasons, we want to check and update the list every five seconds. We can do that by detaching the component's change detector and doing a local check every five seconds.
detectChanges() : void
Checks the change detector and its children.
This can also be used in combination with ChangeDetectorRef
to implement local
change detection
checks.
The following example defines a component with a large list of readonly data. Imagine, the data changes constantly, many times per second. For performance reasons, we want to check and update the list every five seconds.
We can do that by detaching the component's change detector and doing a local change detection check every five seconds.
See ChangeDetectorRef
for more information.
checkNoChanges() : void
Checks the change detector and its children, and throws if any changes are detected.
This is used in development mode to verify that running change detection doesn't introduce other changes.
reattach() : void
Reattach the change detector to the change detector tree.
This also marks OnPush ancestors as to be checked. This reattached change detector will be checked during the next change detection run.
The following example creates a component displaying live
data. The component will detach
its change detector from the main change detector tree when the component's live property
is set to false.
exported from @angular/core/index, defined in @angular/core/src/change_detection/change_detector_ref.ts