I'm running into an error when using ngAnimate and ui-view. Onload or clicking any navigation menu; the angular-animate.js generates a 'object is not a function' error.
Here the main javacsript app:
(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'
});
}
]);
}());
Surprisingly the animation seems to work, but I would prefer solving the error:
This is where the error is generated from in Angular-anumate.js:
function fireDoneCallbackAsync() {
fireDOMCallback('close');
if (doneCallback) {
$$asyncCallback(function () {
doneCallback();
});
}
}
I'm using vs2013 as IDE, all the javascripts files and libraries are inserted at the bottom of the page; I tried injecting through the bundle or regular script as show, but no differences:
@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")
Any help would be appreciated. Thanks
EDITED Even when I comment the app.animation call the error remains (see code above). Just injecting the ngAnimate will generate the error
var app = angular.module("pie", ['ui.router', 'uiGmapgoogle-maps', 'ui.bootstrap', 'ngAnimate']);
Can the IIFE be the cause?
Something really important to remember when using ngAnimate is that the ngAnimate version must be the same as the angular version you're using.
That is to say if you're using v 1.3.4 of angular, you should use v 1.3.4 of angular animate.
Since including the library alone is giving you the error, I expect your versions are not in sync.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With