Change Detection

Last updated 3 months ago

The table implements OnPush change detection which means the dirty checking checks for immutable data types. That means if you do object mutations like:

this.rows[i]['gender'] = 'Female'

The table will not detect a change! Instead if you do a change like this, you need to do:

this.rows[i]['gender'] = 'Female'
this.rows = [...this.rows];

This will cause the table to detect the change and update. Some might have concerns that this is a pricey operation, however, it is MUCH cheaper than running ngDoCheck and constantly diffing the array.

For more information, I recommend this article Angular Change Detection Explained.