angular.js性能问题 [英] angular.js performance issues
问题描述
性能选项卡上Batarang显示,在应用程序的根,角被调用函数看起来像:函数(){VAR E,F,I =一。$的eval(H),M = HC(我,
。
Batarang on the performance tab shows that on the app's root, angular is calling function that looks like that:
function (a){var e,f,i=a.$eval(h),m=hc(i,
.
据batarang这是痛苦的缓慢,当我得到了应用多一点行,它会减慢应用程序和崩溃火狐(虽然Chrome仍然会处理它)。那么到底什么是它做什么?我该如何解决呢?
According to batarang it's painfully slow and when I get little more rows on the app, it slows down the app and crashes Firefox (although Chrome still handles it). So what the heck is it doing? How can I fix that?
推荐答案
东西建立一个角度应用程序你在哪里动态扩展的ngRepeat的内容时要考虑的。您设置每ngRepeat,建立了一个手表。每个{{结合}}或者ngModel你重复做里面,设置了另一个手表,等等。每个那些创建功能和对象实例,并且还需要在每$消化处理。因此,如果您遇到了性能问题,则可能需要实施写出你的数据,而无需设置这些多余的手表定制指令,让你有点更高性能。那我的2美分。
Something to consider when building an Angular application where you're dynamically expanding the contents of an ngRepeat. Every ngRepeat you set up, sets up a watch. Every {{binding}} or ngModel you do inside of that repeat, sets up another watch, and so on. Each of those creates function and object instances, and also needs to be processed on every $digest. So, if your running into performance issues, you may need to implement a custom directive that writes out your data without setting up those superfluous watches, so you're a little more performant. That my 2 cents.
这篇关于angular.js性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!