设置 angular js 应用程序 index.html 页面以仅包含单个控制器

setup angular js application index.html page to include only singe controller

我在后端使用 nodejs 编写了一个 angular 应用程序 (MEAN)。应用程序中有多个模块,因此有多个控制器。

我们必须在 index.html 文件中包含所有控制器,如果我们在任何模块中添加新的控制器。

我已经检查了 运行 在同一个堆栈 (MEAN) 上的其他应用程序,但在源代码中我没有找到所有控制器。

所以请帮助我同样优化我的应用程序。

那么我建议研究一下 Gulp,因为它允许您连接,如果您愿意,还可以缩小您的代码库并将其放入一个文件中。然后可以在 index.html

中引用该单个文件
// Example - Concate the js files together and place them in the dist folder
gulp.task('js', function(){
  var src = ['../../file-name.js'];
  return gulp.src(src)
    .pipe(concat('main.js').on('error', gutil.log))
    .pipe(gulp.dest('dist/js').on('error', gutil.log))
});

这是我在使用 Angular1 时使用的示例。 Gulp 将我所有的目标文件放入 dist 文件夹和我在 index.html 文件中引用的 main.js 文件中。

 <script type="text/javascript" src="js/main.js"></script>