在索引页中包含angularjs的优先顺序? [英] Preference order of including angularjs in index page?

查看:76
本文介绍了在索引页中包含angularjs的优先顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手,正在学习AngularJS并实现了一个项目.出于多种目的,我必须在index.html页面中包含太多JavaScript.我已经阅读了另一个问题,在此之前,我们必须首先包括角线包括任何其他js文件.

I'm newbie and learning to AngularJS and implementing a project. For many purpose, I have to include too many JavaScript in index.html page. I had read on another question that we have to include angular line first, before include any other js file.

我必须包含许多JavaScript,但对于顺序(首选项)感到困惑,必须在index.html页面中包含.请帮助我理解这一点.甚至还有很多类型的角度(动画,路线,),JQuery,TweenMax等.

I have to include many JavaScript but Confused in which order (preference), have to include there in index.html page. Please help me understand this. Even there are many type of angular (animate, route,), JQuery, TweenMax etc.

我将包含JavaScript的index.html页面放在这里.

I'm putting my index.html page included JavaScript here.

<script type="text/javascript" src="js/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script>
<script type="text/javascript" src="js/angular-animate.min.js"></script>
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/TweenMax.min.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<script type="text/javascript" src="js/demo.js"></script>
<script type="text/livescript" src="js/snap.js"></script>

推荐答案

源排序的经验法则如下:

The rule of thumb for source ordering is as follows:

  • 如果要使用jQuery,请首先包含它.根据这些文档.
  • 在其他所有内容之前添加angular.js
  • 包括所有角度扩展库
  • 所有其他第三方库
  • 您的应用程序代码(如果您的所有代码都是与角度相关的,那么除非您以多文件方式使用angular.module(),否则此命令的顺序无关紧要)
  • If you want to use jQuery, include it first. As per these docs.
  • Include angular.js before everything else
  • Include all angular extension libraries
  • All other third party libraries
  • Your app code (if all your code is angular related, then the order of this shouldn't matter, unless you use angular.module() in a multifile way)

此外,请考虑将脚本放置在何处的问题: HEAD中的AngularJS vs身体

Also, look at this question with regards to where exactly to place your scripts: AngularJS in HEAD vs BODY

这篇关于在索引页中包含angularjs的优先顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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