javascript - AngularJS 错误 : Module ngAnimate is not available

标签 javascript angularjs yeoman

我是 Angular 新手,遇到了问题。我使用了 yeoman Angular 生成器并添加了 ngAnimate 模块。当我运行 grunt test我收到以下错误:

Error: [$injector:modulerr] Failed to instantiate module portfolioApp due to:
Error: [$injector:modulerr] Failed to instantiate module ngAnimate due to:
Error: [$injector:nomod] Module 'ngAnimate' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

app.js
'use strict';

angular.module('portfolioApp', [
   'ngAnimate',
   'ngCookies',
   'ngResource',
   'ngSanitize',
   'ngRoute'
])

index.html
<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>

    <!-- build:js scripts/modules.js -->
    <script src="bower_components/angular-animate/angular-animate.js"></script>
    <script src="bower_components/angular-resource/angular-resource.js"></script>
    <script src="bower_components/angular-cookies/angular-cookies.js"></script>
    <script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
    <script src="bower_components/angular-route/angular-route.js"></script>

bower.json
{
  "name": "portfolio",
  "version": "0.0.0",
  "dependencies": {
    "angular": "1.2.0",
    "json3": "~3.2.4",
    "es5-shim": "~2.1.0",
    "jquery": "~1.10.2",
    "greensock": "~1.11.2",
    "angular-animate": "1.2.0",
    "angular-resource": "1.2.0",
    "angular-cookies": "1.2.0",
    "angular-sanitize": "1.2.0",
    "angular-route": "1.2.0"
  },
  "devDependencies": {
    "angular-mocks": "1.2.0",
    "angular-scenario": "1.2.0"
  }
}

我认为应该加载模块,但我不知道我做错了什么。有人有建议吗?

谢谢

最佳答案

我怀疑原因是:如果你运行 grunt test,karma 任务就会运行。 karma 的配置在 karma.conf.js 文件中。在那里,您必须在 files 数组中添加 angular-animate.js。

关于javascript - AngularJS 错误 : Module ngAnimate is not available,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20921594/

相关文章:

javascript - 父子通信未按预期工作

javascript - angularjs $http.get() 调用上的 catch() 不会抑制错误

javascript - INR 货币格式

yeoman - 生成webapp时未定义错误编码

javascript - TypeError : CKEDITOR. 实例未定义 - 对象实例测试给出错误

javascript - 在 jquery 中追加文本长度

javascript - Bootstrap 设置一个工具提示的宽度

javascript - 像 Trello 这样的项目,在 Mongoose 中创建一个合适的数据库

gruntjs - 启用了 sourceMap 选项的 Uglify 与它应该引用的 filerev js 文件不匹配

javascript - 运行 grunt build 命令时 Gruntfile 不工作