所以我一直在尝试将一些外部模块注入(inject)我的应用程序,但似乎无论我做什么,我都会收到错误:
“错误:[$injector:nomod] 模块‘ui-bootstrap’不可用!您要么拼错了模块名称,要么忘记加载它。如果注册模块,请确保将依赖项指定为第二个参数。”
在我的 Karma 日志中。
到目前为止,我已尝试确保它包含在 karma.conf 中,甚至更改了要求的顺序:
files : [
'app/bower_components/angular/angular.js',
'app/bower_components/angular-route/angular-route.js',
'app/bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
'app/bower_components/angular-mocks/angular-mocks.js',
'app/components/**/*.js',
'app/js/app.js',
'app/js/services.js',
'app/js/controllers.js',
'test/unit-tests/*.js'
],
确保它在 html 内:
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>
<script src="js/app.js"></script>
<script src="js/controllers.js"></script>
<script src="js/services.js"></script>
在尝试使用 ngResource 并检查各处的拼写时,我遇到了同样的错误。然而我不断收到同样的错误,我已经在该网站上搜索了数十个问题,但似乎无法解决。如果有人能指出我可能忽略的内容,我将不胜感激。
我的 app.js 文件:
'use strict'
var shopApp = angular.module('shopApp', [
'ngRoute',
'shopServices',
'shopControllers',
'ui-bootstrap'])
最佳答案
如果我没记错的话,ui bootstrap 的模块名称是 ui.bootstrap
而不是 ui-bootstrap
。
关于javascript - 模块 'anyModule' 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27317093/