Cookies concent notice

This site uses cookies from Google to deliver its services and to analyze traffic.
Learn more
Skip to main content
This site is no longer updated.Head to Angular.devHome
/

This is the archived documentation for Angular v17. Please visit angular.dev to see this page for the current version of Angular.

NgZoneOptions

Used to configure event and run coalescing with provideZoneChangeDetection.

      
      interface NgZoneOptions {
  eventCoalescing?: boolean
  runCoalescing?: boolean
}
    

See also

Properties

Property Description
eventCoalescing?: boolean

Optionally specify coalescing event change detections or not. Consider the following case.

      
      <div (click)="doSomething()">
  <button (click)="doSomethingElse()"></button>
</div>
    

When button is clicked, because of the event bubbling, both event handlers will be called and 2 change detections will be triggered. We can coalesce such kind of events to only trigger change detection only once.

By default, this option will be false. So the events will not be coalesced and the change detection will be triggered multiple times. And if this option be set to true, the change detection will be triggered async by scheduling a animation frame. So in the case above, the change detection will only be triggered once.

runCoalescing?: boolean

Optionally specify if NgZone#run() method invocations should be coalesced into a single change detection.

Consider the following case.

      
      for (let i = 0; i < 10; i ++) {
  ngZone.run(() => {
    // do something
  });
}
    

This case triggers the change detection multiple times. With ngZoneRunCoalescing options, all change detections in an event loop trigger only once. In addition, the change detection executes in requestAnimation.