gpt4 book ai didi

javascript - 每个 AngularJS Controller 一个脚本标签?

转载 作者:行者123 更新时间:2023-11-30 05:50:41 25 4
gpt4 key购买 nike

刚开始使用angularjs。真的很棒。我希望我的应用程序尽可能模块化。我的问题:每个 angularjs Controller (服务等)我应该有一个脚本标签吗?有没有办法根据需要从服务器加载我的 Angular Controller (服务等)? Angular 以某种方式做到了吗?我错过了什么吗?

更新

可能是我没说清楚。我希望每个 angularjs Controller (服务等)有一个 javascript 文件。就像我在每个 nodejs 模块服务器端有一个文件一样。

最佳答案

我建议您以 Angular 种子项目为起点。您可以在 Github 上找到它.

This project is an application skeleton for a typical AngularJS web app. You can use it to quickly bootstrap your angular webapp projects and dev environment for these projects.

这是他们建议为 controllers.js 文件采用的样式:

'use strict';

/* Controllers */

function MyCtrl1() {}
MyCtrl1.$inject = [];


function MyCtrl2() {
}
MyCtrl2.$inject = [];

我还建议在开发环境中使用这种方法。您可以在部署到生产环境时压缩和加入文件。

关于javascript - 每个 AngularJS Controller 一个脚本标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15006543/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com