javascript - 加载 Controller 时未加载模块,但我不需要它们

标签 javascript html angularjs

我已经声明了我的模块:

var module = angular.module("app", ["agGrid", "ngAnimate", "ngSanitize", "ui.bootstrap", "ngDialog"]);

然后是我的 Controller :

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.

我不明白为什么当我的 Controller 加载时,它要求将我的模块中的所有依赖项一起包含在内。我的其他 Controller 并非如此:

angular.module("app").controller("modalCtrl", ["$scope", "shareDataService", "ngDialog", "getDataService", function ($scope, shareDataService, ngDialog, getDataService) {
//stuff
}]);

例如。

问题 Controller 代表一个弹出窗口,这可能是问题所在吗?或者我错过了一些显而易见的事情?

最佳答案

您没有包含 ng-animate 库(将 X.Y.Z 更改为您想要使用的版本)。

<script src="//ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/angular-animate.js">

如果不需要它,只需从模块定义中删除“ngAnimate”即可。

关于javascript - 加载 Controller 时未加载模块,但我不需要它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33737679/

相关文章:

javascript - 使用铆钉制作模板时如何为值添加前缀?

javascript - 如何中止ajax请求

javascript - 优先将元素插入数组

html - 更改 :before when :hover over main DIV?

javascript - jQuery:获取最后一个 'td' 包含一些文本而不使用每个

angularjs - 多个指令 [指令#1,指令#2] 要求隔离范围

javascript - Canvas 在方形预览框中显示部分悬停区域

angularjs - RxJS Observables,什么时候退订?

javascript - 自定义 Angular 窗口依赖项

javascript - 实现显示更多 - 在页面上显示更少的文本