gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-27 23:40:16 24 4
gpt4 key购买 nike

我已经声明了我的模块:

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/

24 4 0
文章推荐: c++ - 是否有一个函数接受 2 个指针并返回一个非 NULL 的指针?
文章推荐: css - 使用
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com