AngularJS: ng-repeat with dynamic list, without rebuilding entire DOM tree?

前端 未结 3 1786
轻奢々
轻奢々 2020-12-08 19:26

I\'m using ng-repeat on a table row with data from a JSON array retrieved from a server. My goal is to have the list update automatically whenever an item is added, removed

3条回答
  •  遥遥无期
    2020-12-08 19:59

    I'm planning to build the following solution myself eventually though it's still in my product backlog.

    The problem with ng-repeat is it will remove items from the DOM when it needs to so for a table it would mean it will resize and such, but if the data is dynamic, it may flicker because the data changed around and the table size is shifting. Particularly during paging because the whole page may not have loaded yet.

    To get around this flickering, the table must not change its number of rows. Instead have an ng-repeat of "displayed" data and just change it as needed without adding or removing items from the array.

提交回复
热议问题