detectChanges method

  1. @Deprecated('Breaks assumptions around change detection and will be removed')
void detectChanges()

Forces synchronous change detection of this component and its children.

WARNING: In practice, this API was not intended to be public with perhaps the exception of a select few specialized leaf components, and is being completely removed in a future version of Angular.

Try instead:

  • Simply removing it, and seeing if it breaks your app.
  • Using ChangeDetectionStrategy.onPush and markForCheck instead.

If all else fails, it is strongly preferable to use our explicit API for forcing more change detection, NgZone.runAfterChangesObserved. It is also worth filing a bug if this is needed.

Implementation

@Deprecated('Breaks assumptions around change detection and will be removed')
void detectChanges() {
  detectChangesDeprecated();
}