当我部署它并在浏览器中运行它时,我的应用程序运行良好
我可以成功访问我所有的控制器/服务。它们通过子模块链接在一起。
我使用子模块来更好地为 ui-router 组织状态/路由。(以前我们在 app dot js 文件中有我们所有的状态。大约有 50 个。现在它们被组织成更小的模块)。
app.js [模块文件]
var phpApp = angular.module("phpApp",
[
"ui-router"
"phpApp.components" , ...
]).config(...).run(...);
components.js [模块文件,包含状态/路由]
var ComponentModule = angular.module("phpApp.components",
[
"ui-router"
"phpApp.components.user" ,
"phpApp.components.client"
...
]).config(...).run(...);
user.js [模块文件,包含状态/路由]
var UserModule = angular.module("phpApp.components.user",
[
"ui-router"
]).config(...).run(...);
user-controller.js // 加载正常;是一个控制器。
angular.module('phpApp.components').controller('UserController', ....);
client-controller.js // 不加载!找不到“phpApp.components”模块...
angular.module('phpApp.components').controller('ClientController', ...);
我的 index.html 文件按以下顺序加载脚本:
<script src="app.js"></script>
<script src="components/components-module.js"></script>
<script src="components/user/user-module.js"></script>
<script src="components/client/client-module.js"></script>
...
<script src="components/user/user-controller.js"></script>
<script src="components/client/**client-controller.js**"></script>
我不明白。我的客户端控制器在我的用户控制器之后加载......但它无法找到正确的模块?
我得到错误:
Uncaught Error: [$injector:nomod] Module 'phpApp.components'
is not available! You either misspelled the module name or
forgot to load it.
在这一点上,我感到非常困惑和沮丧。我不确定我哪里出错了。