如何使用angular.js包含.js文件

时间:2015-10-17 08:32:36

标签: javascript angularjs

我需要使用angular.js动态包含javascript文件。假设我有以下项目html视图结构。

1-index.html.

     a)hod.html-hodcontroller.js
         i)home.html.-homecontroller.js
         ii)about.html.-aboutcontroller.js

     b)Princpal.html-princpalcontroller.js

         i)home.html-homecontroller.js
          ii)about.html -aboutcontroller.js

让我解释一下上面的结构。我有一个母版页(i.e-index.html)。 hod.html and Princpal.html是index.html页面的部分视图。每个home.html and about.html都是hod.htmland Princpal.html的局部视图,所以最后这些是嵌套视图。我在index.html页面中一次包含所有js文件但是这里我需要任何局部视图在索引页面中附加只有相关的.js文件将附加在索引页面而不是所有页面。所以请帮我使用angular.js。

1 个答案:

答案 0 :(得分:0)

您要做的不是创建角度应用的最佳方式。 通常您希望所有代码都在一个js文件中。

当然,当你开发它们将是不同的文件,所以你应该使用 像 Grunt Gulp 这样的任务运行员为你做这件事。

我建议您使用 Yeomen generator 使用angular generator

它将使用Grunt和其他有趣的东西为您设置一个有效的角应用程序。

相关问题