AngularJS UI的引导模式实例问题 [英] AngularJS ui-bootstrap modal instance issue

查看:232
本文介绍了AngularJS UI的引导模式实例问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有AngularJS应用程序(版本1.4.7)和ui.bootstrap的最新版本。当我尝试注入问题处理$ uibModalInstance会抛出错误未知提供商:$ uibModalInstanceProvider

I have AngularJS app (version 1.4.7) and latest version of ui.bootstrap. Problem occurs when I try to inject $uibModalInstance which throws error Unknown provider: $uibModalInstanceProvider

下面是控制器code:

Here is controller code:

/**
 * @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;
}

任何想法,可能会导致这种行为?

Any idea what could cause this kind of behavior?

推荐答案

什么引起的行为如下:

$ uibModal.open()返回 $ modalInstance 要求的依赖注入 $ uibModalInstance ClientModalInstController 控制器。我看不到code为 ClientModalInstController ,但它需要有 $ uibModalInstance 注入它,这比 $ uibModal

$uibModal.open() returns a $modalInstance which requires a dependency injection of $uibModalInstance into the ClientModalInstController controller. I can't see the code for ClientModalInstController, but it needs to have $uibModalInstance injected into it, which is different than $uibModal

您可以看到这样的例子在UI的引导文档模态的例子的JavaScript的标签:的 http://angular-ui.github.io/bootstrap/

You can see an example of this in the javascript tab of the Modal example in the ui-bootstrap docs: http://angular-ui.github.io/bootstrap/

向下滚动到文档的模态节,并期待在code中的JavaScript选项卡的 ModalInstanceCtrl 和注入的依赖关系。

Scroll down to the Modal section of the docs and look at the code in the Javascript tab for the ModalInstanceCtrl and its injected dependencies.

这篇关于AngularJS UI的引导模式实例问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆