ChrisFletcher
ChrisFletcher

Reputation: 1042

Angular is undefined in angular-animate

I'm building an angular application, I've got a couple of modules with services and controllers all of which are functioning correctly. I've just added angular-animate to my list of scripts, which are loaded from a cshtml file before my app.js (slightly redacted):

<script type="text/javascript" src="~/lib/angularjs/angular.js" defer></script>
<script type="text/javascript" src="~/lib/angular-cookies/angular-cookies.js" defer></script>
<script type="text/javascript" src="~/lib/ui-router/angular-ui-router.js" defer></script>
<script type="text/javascript" src="~/lib/angular-animate/angular-animate.js"></script>

When angular-animate runs through I get an error saying "noop cannot be found on undefined", see the top of angular-animate:

(function(window, angular, undefined) {'use strict';

var noop        = angular.noop;
var extend      = angular.extend;
var jqLite      = angular.element;
var forEach     = angular.forEach;

It seems the 'angular' being passed in is null. But angular-cookies has an identical header at the top and a non-null angular is passed in. All the files are valid and I'm running versions which match my angular version.

Upvotes: 1

Views: 759

Answers (1)

ChrisFletcher
ChrisFletcher

Reputation: 1042

As Pryt pointed out in a comment, the problem was that the other script tags had a defer whereas the new one did not. This caused angular-animate to run before angular had loaded.

Upvotes: 1

Related Questions