【发布时间】:2016-02-09 13:38:27
【问题描述】:
我有 AngularJS 应用程序(版本 1.4.7)和最新版本的 ui.bootstrap。当我尝试注入 $uibModalInstance 时出现问题,这会引发错误Unknown provider: $uibModalInstanceProvider
这是控制器代码:
/**
* @constructor
* @param $uibModal
*/
function ClientsController($uibModal)
{
var _this = this;
_this.$uibModal = $uibModal;
}
/**
*
*/
ClientsController.prototype.create = function()
{
var instance = this.$uibModal.open(
{
animation: true,
templateUrl: 'modules/clients/views/modal/client.html',
controller: 'ClientModalInstController as ctrl',
size: 'lg'
}
);
};
这里是模态控制器
ClientModalInstController.$inject = [
'$uibModalInstance'
];
/**
* @constructor
* @param $uibModalInstance
*/
function ClientModalInstController($uibModalInstance)
{
var _this = this;
_this.$uibModalInstance = $uibModalInstance;
}
知道什么会导致这种行为吗?
【问题讨论】:
-
你在哪里注册
ClientModalInstController作为控制器? -
那个代码在$inject块上面,我只是没有在这里显示
-
这里似乎可以正常工作~plnkr.co/edit/Z3UNct38ZGCsvMHTZ4M6?p=preview。一定是你缺少的东西。您的模块的依赖项是什么?
-
我已经看到了 plnkr,但我无法弄清楚我错过了什么。我已将 ui.bootstrap 添加到 modul。有线的事情是,我能够打开模态,但是当我尝试注入模态实例时,它会中断
-
尝试将
ng-strict-di属性添加到带有ng-app的元素。它可能有助于指出任何错误。
标签: angularjs angular-bootstrap