uncaught object error: can't inject ngAnimate

℡╲_俬逩灬. 提交于 2019-12-10 15:00:04

问题


I can't instantiate my app when I try to inject 'ngAnimate' like so:

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

I get an error Uncaught object from angular.js line 78

I installed ngAnimate using bower. Here's my 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"
  }
}

And I include all the scripts in my 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>

If I remove 'ngAnimate' from my module declaration everything works. Why can't I use ngAnimate?


回答1:


Ran into the same problem. You have to match the version of angular to angular animate.

change:

"angular-animate": "1.2.6"




回答2:


I ran into a similar situation.

If you are using karma you need to manually enter the path to angular-animate under vendor_files.js in your build.config.js (grunt task) that solves the loading dependency.

After adding I got another error which was solved by declaring it last in vendor_files.js



来源:https://stackoverflow.com/questions/24065124/uncaught-object-error-cant-inject-nganimate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!