简体   繁体   English

由于以下原因,无法实例化模块ngAnimate:

[英]Failed to instantiate module ngAnimate due to:

I am getting problems with building my Angular JS project. 我在构建我的Angular JS项目时遇到了问题。

It says Failed to instantiate module ngAnimate due to: 它说无法实例化模块ngAnimate,原因是:

I have put all my services into [] but the ngAnimate is not working. 我已将所有服务放入[]但ngAnimate无效。

Here is the app 这是应用程序

Failed to instantiate module ngAnimate due to:'use strict'; 由于以下原因无法实例化模块ngAnimate:'use strict';

/* global app:true */

var app = angular
    .module('angNewsApp', [
        'ngCookies',
        'ngResource',
        'ngSanitize',
        'ngRoute',
        'ngAnimate',
        'firebase'
    ])
    .config(['$routeProvider', function($routeProvider) {
        $routeProvider
            .when('/', {
                templateUrl: 'views/posts.html',
                controller: 'PostsCtrl'
            })
            .when('/posts/:postId', {
                templateUrl: 'views/showpost.html',
                controller: 'ViewPostCtrl'
            })
            .otherwise({
                redirectTo: '/'
            });
    }])

.constant('FIREBASE_URL', 'https://scorching-fire-4068.firebaseio.com/');

app.directive('post', function() {
  var controller = function($scope) {
    $scope.showAnswer = false;
  };

  return {
    restrict: 'C',
    scope: false,
    controller: controller
  };
});

app.animation('.answer-animation', function(){

  CSSPlugin.defaultTransformPerspective = 1000;

  TweenMax.set($("div.back"), {rotationX:-180});

  $.each($("div.box"), function(i,element)
  {
    console.log(element);
    var frontCard = $(this).children("div.front")
    var backCard = $(this).children("div.back")
    var tl = new TimelineMax({paused:true})

    tl
      .to(frontCard, 1, {rotationX:180})
      .to(backCard, 1, {rotationX:0},0)

    this.animation = tl;
  });

  return {
    beforeAddClass: function(element, className, done){
      if (className == 'answer') {
        var el = element.find('.box')[0];
        el.animation.play();
      }
      else {
        done();
      }
    },

    beforeRemoveClass: function(element, className, done) {
      if (className == 'answer') {
        var el = element.find('.box')[0];
        el.animation.reverse();
      }
      else {
        done();
      }
    }
  };
});

And the index.html script tags 和index.html脚本标签

 <!-- build:js scripts/vendor.js -->
    <!-- bower:js -->
    <script src="bower_components/jquery/dist/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/angular-route/angular-route.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>
    <!-- endbower -->
    <!-- endbuild -->

        <!-- build:js({.tmp,app}) scripts/scripts.js -->
        <script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.16/angular-animate.js"></script>
        <script src="scripts/app.js"></script>
        <script src='scripts/services/posts.js'></script>
        <script src="scripts/filters/url.js"></script>
        <script src="scripts/controllers/posts.js"></script>
        <script src="scripts/controllers/postview.js"></script>
        <script src="scripts/controllers/nav.js"></script>
        <script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.11.7/TweenMax.min.js"></script>

        <!-- endbuild -->

Ok so this is the answer, 好的,这就是答案,

<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.16/angular-animate.js"></script>

<script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.11.7/TweenMax.min.js"></script>

Were both external library loads, which meant they couldn't go through the minification process. 两个外部库加载,这意味着他们无法完成缩小过程。

I solved this by installing the libs through bower, and adding them like it. 我通过bower安装libs并像它一样添加它来解决这个问题。

<script src="/bower_components/angular-animate/angular-animate.js"></script>
<script src="/bower_components/greensock/src/minified/TweenMax.min.js"></script> 

Just adding this in case it helps someone else! 只是添加它,以防它帮助其他人!

I had the same problem but my cause was that I had the src in the script tag for angular-animate incorrect - I'd pasted bower_components/angular/angular-animate.js not the correct reference which was: 我遇到了同样的问题,但我的原因是我在脚本标签中有src用于角度动画不正确 - 我粘贴了bower_components / angular / angular-animate.js而不是正确的引用,它是:

<script src="bower_components/angular-animate/angular-animate.js"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未能实例化模块启动器 - Failed to instantiate module starter due 由于实例化模块angularApp失败 - Failed to instantiate module angularApp due to 由于在AngularJS中无法实例化模块应用? - Failed to instantiate module app due to in AngularJS? Angular JS:由于以下原因,无法实例化模块测试: - Angular JS : Failed to instantiate module test due to: AngularJS/TypeScript:由于服务无法实例化模块 - AngularJS/TypeScript: Failed to instantiate module due to service 出现错误“由于以下原因,无法实例化模块{0}:\\ n {1}” - Getting error “Failed to instantiate module {0} due to:\n{1}” 错误:无法实例化模块restangular,原因是:'_'未定义 - Error: Failed to instantiate module restangular due to: '_' is undefined 由于以下原因,无法实例化模块应用程序:错误:模块“应用程序”不可用 - Failed to instantiate module Application due to: Error: Module 'Application' is not available 由于以下原因而无法实例化模块[模块名称]:错误:[$ injector:modulerr] - Failed to instantiate module [module name] due to: Error: [$injector:modulerr] 未捕获的错误:[$ injector:modulerr]由于实例化模块polmgr而失败。 - Uncaught Error: [$injector:modulerr] Failed to instantiate module polmgr due to
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM