【发布时间】:2016-04-02 11:53:11
【问题描述】:
我正在尝试创建一个弹出并提供不同菜单选项的简单模式。这应该很容易,我在 ui bootstrap 网站上关注了 Plunker for modals,但出现错误:
$uibModal 是一个未知的提供者
这是角码:
angular.module('billingModule', ['ngAnimate', 'ui.bootstrap']);
angular.module('billingModule').controller('StoreBillingCtrl', function ($scope, $uibModal) {
$scope.openStoreBilling = function () {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'storeBillingContent.html',
controller: 'ModalInstanceCtrl',
});
};
});
angular.module('billingModule').controller('OfficeBillingCtrl', function ($scope, $uibModal) {
$scope.openOfficeBilling = function () {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'officeBillingContent.html',
controller: 'ModalInstanceCtrl',
});
};
});
angular.module('billingModule').controller('ModalInstanceCtrl', function ($scope, $uibModalInstance) {
$scope.close = function () {
$uibModalInstance.dismiss();
}
});
我阅读了错误文档并意识到这是一个依赖错误。但我只是不明白我哪里出错了。我有 angular 1.4.8 和 ui-bootstrap 0.14.3。
这是我添加的脚本:
<head runat="server">
<title>DP Billing</title>
<link href="../CSS/bootstrap.css" rel="stylesheet" />
<link href="../CSS/base.css" rel="stylesheet" />
<script src="../Scripts/angular.js"></script>
<script src="../Scripts/angular-animate.js"></script>
<script src="../Scripts/angular-ui/ui-bootstrap-tpls.js"></script>
<script src="../Scripts/billing-modals.js"></script>
</head>
【问题讨论】:
-
请检查您是否添加了
script标签。 -
我编辑了我的问题以包含我为 html 提供的脚本标签。这是你的要求吗?
-
所以我想通了。事实证明 1.4.8 不适用于 ui-bootstrap。最多只能工作 1.4.7。为什么我不知道。
-
奇怪,但似乎 1.4.8 可以与 ui-bootstrap 0.14.3 一起使用。您可以更改this plunkr 以重现您的问题吗?
-
我试图在 plunkr 中复制它,但不能。然后我将我的项目切换回 1.4.8 进行测试,它再次停止工作。然后我决定重新安装 angularJS 以及自项目开始以来我安装的所有包。在此之后它又开始工作了。我唯一的理由是 angular.js 文件在某处被损坏或更改。我很抱歉现在问了这样一个毫无价值的问题。
标签: javascript angularjs angular-ui-bootstrap