AngularJS:在解析HTML时间表事件 [英] AngularJS: Parse HTML events in timeline

查看:142
本文介绍了AngularJS:在解析HTML时间表事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我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.

这篇关于AngularJS:在解析HTML时间表事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆