我已宣布我的模块:
var module = angular.module("app", ["agGrid", "ngAnimate", "ngSanitize", "ui.bootstrap", "ngDialog"]);
然后我的控制器:
angular.module("app").controller("boxLadderCtrl", ["$scope", function ($scope) {
//stuff
}]);
相应的HTML:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="../Scripts/angular.js"></script>
<script src="../assets/controller/applicationModule.js"></script>
<script src="../assets/controller/Box_Ladder_controller.js"> </script>
<script src="../node_modules/ag-grid-2.2.0/dist/ag-grid.js"></script>
</head>
<body ng-app="app">
<div ng-controller="boxLadderCtrl">
</div>
</body>
</html>
我收到以下错误:
Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module ngAnimate due to:
Error: [$injector:nomod] Module 'ngAnimate' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
我不明白为什么,当我的控制器加载时,它要求我的模块中的所有依赖项都包含在内。对于我的其他控制器来说情况并非如此:
angular.module("app").controller("modalCtrl", ["$scope", "shareDataService", "ngDialog", "getDataService", function ($scope, shareDataService, ngDialog, getDataService) {
//stuff
}]);
例如。
问题控制器代表一个弹出窗口,这可能是问题吗?或者我错过了一些明显的东西?
答案 0 :(得分:1)
您没有包含ng-animate lib(将X.Y.Z更改为您要使用的版本)。
<script src="//ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/angular-animate.js">
如果您不需要,只需从模块定义中删除"ngAnimate"
。