在HEAD VS BODY AngularJS [英] AngularJS in HEAD vs BODY

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

问题描述

在所有的AngularJS实施例中,角库被放置在文档的HEAD标签。我已经在HTML5的样板布局构建的现有项目。这定义了JS库应放置在DOM前的最底部< / BODY方式> 标签

In all of the AngularJS examples, the Angular library is placed in the HEAD tags of the document. I have an existing project that has been built upon the HTML5 Boilerplate layout. This defines that JS libraries should be placed at the very bottom of the DOM before the </BODY> tag.

请问AngularJS需要放置在头上?

Does AngularJS need to be placed in the HEAD?

推荐答案

AngularJS并不需要放置在头部,实际上你通常不应该,因为这将阻止加载HTML。

AngularJS does not need to be placed in the HEAD, and actually you normally shouldn't, since this would block loading the HTML.

不过,当你在页面底部加载AngularJS,你将需要使用 NG-斗篷纳克绑定避免的未编译内容闪。请注意,您只需要你的index.html网页上使用NG-斗篷/ NG绑定。 NG-视图或其它角度构造用于初始页面加载后附加内容拉当NG-包括或内容将被角在显示之前编译。

However, when you load AngularJS at the bottom of the page, you will need to use ng-cloak or ng-bind to avoid the "flash of uncompiled content". Note that you only need to use ng-cloak/ng-bind on your "index.html" page. When ng-include or ng-view or other Angular constructs are used to pull in additional content after the initial page load, that content will be compiled by Angular before it is displayed.

另请参阅 http://stackoverflow.com/a/14076004/215945

这篇关于在HEAD VS BODY AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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