AngularJS:在解析HTML时间表事件时间表、事件、AngularJS、HTML

由网友(ι 温浅 suk)分享简介:在我angularjs应用程序的调试,我发现了很多的解析HTML 的在开发工具的事件。 During the debugging of my angularjs application, I found a lot of parse html events in the dev tools. 时间轴说,此事件...

在我angularjs应用程序的调试,我发现了很多的解析HTML 的在开发工具的事件。

During the debugging of my angularjs application, I found a lot of parse html events in the dev tools.

时间轴说,此事件是由 jQuery.extend.buildFragment 调用,这是我很难理解,有什么指令调用的解析HTML 的

The timeline says that this event is invoked by jQuery.extend.buildFragment and it's hard for me to understand, what directive invokes parse html.

我如何检测,到底是什么导致的解析HTML 的事件?也许原因可能是在 NG-重复,但我不知道。

How can I detect, what exactly causes parse html events? Probably the reason could be in the ng-repeat, but I'm not sure.

这些事件减慢 $范围。$适用为好。

推荐答案

在各部分的HTML角度将触发解析HTML事件一样,NG-包括NG-重复,指令和$消化周期。

Every partial html in angular will trigger Parse HTML event, like ng-includes, ng-repeats, directives, and $digest cycles.

此外使用jQuery会给你initalize jQuery的实例很多开销。 jQuery的或jQlite buildFragment被调用时,你或指示或角通话element.html(标签的东西'),这反过来写的innerHTML这会导致浏览器和角步行那些孩子找到更多的指令,并编译直到解析HTML事件的完成。

Also using jQuery will give you a lot of overhead for initalize jquery instances. jQuery or jQlite buildFragment is called when you or directives or angular call element.html('something tags'), which in turn write to innerHTML which cause parse HTML event in browser and angular walk those children to find more directives and compile those until its complete.

要尽量减少这些,你需要批量处理的,但棱角分明的性质将难以直接进行。可能是你可以尝试使用一次性绑定语法::在角1.3+或做那么多观察,所以角就不必一次又一次地解析HTML。

To minimize those, you need to batch process those, but nature of angular will be hard to do directly. May be you can try to use one-time binding syntax :: in angular 1.3+ or make less watchers, so angular won't have to parse html again and again.

阅读全文

相关推荐

最新文章