我有大量数据,并尝试在 AngularJS 的表格中显示这些数据(带有过滤和排序)。为此,我尝试使用 ng-Table,但是当数据太多(> 1000 行)时,它在远程服务器上开始变慢,当数据太多(> 5000 行)时,包含此表的页面甚至不会在本地主机上加载机器。据我了解,过滤和排序需要从数据库加载所有数据,可能有人知道一些技巧而不加载所有数据。或者可能有人知道 Angular 的另一个表格插件。
感谢您的帮助。
最佳答案
您需要的信息在这里:http://tech.small-improvements.com/2013/09/10/angularjs-performance-with-large-lists/
建议是:
- Paginate the rows, they can't see all 2000 rows at one time anyway
- Render the list without data binding
- Do not use a inline method call for calculating the data
- Use two lists (one for the view to display, one as data source)
- Use ng-if instead of ng-show for additional templates
- Do not use AngularJS directives ng-mouseenter, ng-mouseleave, etc.
- Tuning hint for filtering: Hide elements with ng-show that are excluded
- Tuning hint for filtering: Debounce input
您的过滤和排序可能是问题所在,请在 Controller 中应用过滤器并在那里对它们进行排序。
关于AngularJS ngTable 在处理大量数据时速度很慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25219103/