未捕获的对象错误:无法注入ngAnimate

时间:2014-06-05 16:10:53

标签: javascript angularjs angular-ui bower ng-animate

当我尝试注入' ngAnimate'时,我无法实例化我的应用。像这样:

var app = angular.module('musicsa', [
  'ngCookies',
  'ngResource',
  'ngSanitize',
  'ui.router',
  'firebase',
  'ngAnimate'
]) 

我从angular.js第78行收到错误Uncaught object

我使用bower安装了ngAnimate。这是我的bower.json

{
  "name": "ang-changeorg",
  "version": "0.0.0",
  "dependencies": {
    "angular": "1.2.6",
    "json3": "~3.2.6",
    "es5-shim": "~2.1.0",
    "jquery": "~1.10.2",
    "bootstrap": "~3.0.3",
    "angular-resource": "1.2.6",
    "angular-cookies": "1.2.6",
    "angular-sanitize": "1.2.6",
    "firebase": "~1.0.11",
    "angularfire": "~0.7.1",
    "spin.js": "~2.0.0",
    "angular-ui-router": "~0.2.10",
    "angular-animate": "~1.2.16"
  },
  "devDependencies": {
    "angular-mocks": "1.2.6",
    "angular-scenario": "1.2.6"
  },
  "resolutions": {
    "angular": "1.2.6"
  }
}

我在index.html中包含了所有脚本:

<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.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/firebase/firebase.js"></script>
<script src="bower_components/firebase-simple-login/firebase-simple-login.js"></script>
<script src="bower_components/angularfire/angularfire.js"></script>
<script src="bower_components/spin.js/spin.js"></script>
<script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="bower_components/angular-animate/angular-animate.js"></script>

如果我从模块声明中删除'ngAnimate',一切正常。为什么我不能使用ngAnimate?

2 个答案:

答案 0 :(得分:6)

遇到同样的问题。您必须将角度与角度动画的版本相匹配。

变化:

“angular-animate”:“1.2.6”

答案 1 :(得分:0)

我遇到了类似的情况。

如果您正在使用业力,则需要在build.config.js(grunt任务)中的vendor_files.js下手动输入angular-animate的路径,以解决加载依赖性。

添加后我得到了另一个错误,通过在vendor_files.js中声明它最后解决了