ngFor reprints all dom when i add item in array at first place

Viewed 113

I am having a use-case where i have to insert an element in table in every 6 seconds and table size can be maximum 100. problem is that after every 6 seconds new element inserts into first place(0th index) and last element removes(99th index). i implemented this with angular material mat-table but it reprints whole 100 row dom in every 6 seconds. i googled then i got its a problem of ngFor which re-prints whole dom when array is changed(element at first index change)

i have used trackBy but didn't get any success as in my use-case element added to first place(i am using unshift for that) so whole array is changed(according to ngFor).

0 Answers
Related