AngularJS Infinite Scrolling with lots of data

后端 未结 6 824
隐瞒了意图╮
隐瞒了意图╮ 2021-01-30 01:05

So I\'m trying to create an infinite scrolling table using AngularJS, similar to this: http://jsfiddle.net/vojtajina/U7Bz9/

The problem I\'m having is that in the jsfidd

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-30 01:29

    A couple of things:

    1. "Infinite scrolling" to "1,000,000" rows is likely to have issues regardless of the framework, just because you've created millions and millions of DOM nodes (presuming you have more than one element in each record)

    2. The implementation you're looking at doing with

    3. {{item.foo}}
    4. or anything like that will have issues very quickly for one big reason: {{item.foo}}} or any ngBind like that will set up a $watch on that field, which creates a lot of overhead in the form of function references, etc. So while 10,000 small objects in an "array" isn't going to be that bad... 10,000-20,000 additional function references for each of those 10,000 items will be.

    What you'd want to do in this case would be create a directive that handles the adding and removing of DOM elements that are "too far" out of view as well as keeping the data up to date. That should mitigate most performance issues you might have.

    ... good infinite scrolling isn't simple, I'm sorry to say.

提交回复
热议问题