Why doesn't change detection happen here when [value] has changed?

Here is my pluker: https://plnkr.co/edit/QPqciUngXeby2uECbokx?p=preview (You may have to click on a stop and start several times so that it can load correctly)

The table does not change.

But when you take

changeDetection: ChangeDetectionStrategy.OnPush 

out, the table changes.

I understand that with OnPush, when @Input changes, change detection will fire. In this case, @Input is [value], which refers to this.testData.

Why does this not change?

+1
angular
Feb 17 '17 at 8:52
source share
1 answer

Because when changes are detected, onPush is executed when the input changes or when listening to the event that was listened to.

If you change this.testData , you must perform a discovery change to update the binding [value]="testData" . If this happens, change detection will be performed for <p-dataTable> because its input has changed.

There are no changes on the App tab, so no changes were found.

You can mark the App for validation with ChangeDetectorRef.markForCheck()

Plunger example

+1
Feb 17 '17 at 8:58
source share



All Articles