Why event triggers ChangeDetection even if OnPush strategy is ON?

后端 未结 1 1650
灰色年华
灰色年华 2021-01-18 19:04

When we use Default Strategy this guys could trigger Change Detection(of course except input params):

  • user events
  • timers
  • aja
相关标签:
1条回答
  • 2021-01-18 20:01

    OnPush is defined this way.

    It triggers change detection

    • when a DOM event the component listens to was received
    • when the |async pipe receives a new event
    • when an @Input() was updated by change detection.
    • when explicitly registering the component to be checked the next change detection turn using ChangeDetectorRef::markForCheck

    ChangeDetectionStrategy.Default triggers change detection for every async callback called within Angulars zone (every DOM even listened to within the Angular application, every Observable event or completed Promise, setTimeout, ...)

    0 讨论(0)
提交回复
热议问题