ngAnimate对象未设置为函数

bou*_*pat 2 angularjs angular-ui-router

我在使用ngAnimate和ui-view时遇到错误.上载或单击任何导航菜单; angular-animate.js生成'对象不是函数'错误.

这里是主要的javacsript应用程序:

(function () {
'use strict';
var app = angular.module("pie", ['ui.router', 'uiGmapgoogle-maps', 'ui.bootstrap', 'ngAnimate']);

app.config(["$stateProvider", "$locationProvider", "$urlRouterProvider",
function ($stateProvider, $locationProvider, $urlRouterProvider) {

    $locationProvider.html5Mode({ enabled: true, requireBase: false });

    $urlRouterProvider.otherwise('/Welcome');
    $stateProvider
        .state("Welcome", {
            url: "/Welcome",
            templateUrl: "../Scripts/Home/WelcomeView.html",
            controller: "WelcomeController"
        })
        .state("About", {
            url: "/About",
            templateUrl: "../Scripts/Home/AboutView.html",
            controller: "AboutController"
        })
        .state("Contact", {
            url: "/Contact",
            templateUrl: "../Scripts/Home/ContactView.html",
            controller: "ContactController"
        })
        .state("Login", {
            url: "/Account/Login"
        })
        .state("Register", {
            url: "/Account/Register"
        })
        .state("ForgotPassword", {
            url: "/Account/ForgotPassword"
        });
}]);

//app.animation('.view-animation', function () {
//    return {
//        enter: function (element, done) {
//            element.css({
//                opacity: 0.5,
//                position: "relative",
//                top: "10px",
//                left: "20px"
//            }).animate({
//                top: 0,
//                left: 0,
//                opacity: 1
//            }, 1000, done);
//        }
//    };
//});

app.config(['$httpProvider', function ($httpProvider) {
    //Http Intercpetor to check auth failures for xhr requests
    $httpProvider.interceptors.push('AuthHttpResponseInterceptor');
}]);

// Google map
app.config(['uiGmapGoogleMapApiProvider', function (uiGmapGoogleMapApiProvider) {
    uiGmapGoogleMapApiProvider.configure({
        //    key: 'your api key',
        v: '3.17',
        libraries: 'weather,geometry,visualization'
    });
}
]);

}());
Run Code Online (Sandbox Code Playgroud)

令人惊讶的是动画似乎有效,但我更愿意解决错误:

这是在Angular-anumate.js中生成错误的地方:

function fireDoneCallbackAsync() {
                                          fireDOMCallback('close');
                                          if (doneCallback) {
                                              $$asyncCallback(function () {
                                                  doneCallback();
                                              });
                                          }
                                      }
Run Code Online (Sandbox Code Playgroud)

我使用vs2013作为IDE,所有javascripts文件和库都插在页面底部; 我尝试通过捆绑或常规脚本注入show,但没有区别:

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/bundles/angularjs")
@*@Scripts.Render("~/bundles/angularAnimate")*@
<script src="~/Scripts/angular-animate.js"></script>
@Scripts.Render("~/bundle/app")
Run Code Online (Sandbox Code Playgroud)

任何帮助,将不胜感激.谢谢

编辑 即使我评论app.animation调用错误仍然存​​在(参见上面的代码).只需注入ngAnimate就会产生错误

var app = angular.module("pie", ['ui.router', 'uiGmapgoogle-maps', 'ui.bootstrap', 'ngAnimate']);
Run Code Online (Sandbox Code Playgroud)

IIFE可以成为原因吗?

Ed *_*ffe 11

使用时要记住的一件非常重要的事情ngAnimatengAnimate版本必须与您正在使用的角度版本相同.

也就是说,如果你使用v 1.3.4的角度,你应该使用v 1.3.4的角度动画.

由于仅包含库会给您错误,我希望您的版本不同步.