【问题标题】:Angular-modal-service does not show modalAngular-modal-service 不显示模态
【发布时间】:2015-09-23 14:29:41
【问题描述】:

尝试设置一个(我认为)相对简单的模式来显示网站 cookie 策略。

政策适用于/cookiepolicy。检查并且该链接工作得很好。

然后我创建了一个按钮(调用代码)

<a class="btn btn-default" href ng-click="showCookie()">Read More</a>

因为我只想调用 url 的模态,所以 html 中没有添加任何内容。

调用模态的函数(也被调用并根据最后一行报告成功。)

app.controller('IndexController', function($scope, ModalService) {
    $scope.showCookie = function (data) {
        ModalService.showModal({
            templateUrl: "/cookie-policy",
            controller: "ModalController"
        }).then(function (modal) {

            //it's a bootstrap element, use 'modal' to show it
            modal.element.modal;
            modal.close.then(function (result) {
                console.log(result);
            });
        });
    }
});

模态也有自己的控制器

betchaHttp.controller('ModalController', function($scope, close) {

    // when you need to close the modal, call close
    close("Success!");
});

问题是当我按下它时,页面上什么也没有出现,也没有错误消息。我是否遗漏了一些相当明显(或不那么明显)的东西

【问题讨论】:

  • 我猜应该是modal.element.modal();
  • @akhurad 我刚刚回答了确切的建议
  • @scniro 我忘记刷新页面了。无法阅读您的答案。
  • 您在这方面取得了进展吗?我的回答对你有帮助吗?
  • 抱歉,错过了回答并感谢您。是的,你的答案是正确的,只是我错过了括号

标签: javascript html angularjs twitter-bootstrap modal-dialog


【解决方案1】:

幸运的是,这只是您的一个小语法错误。观察你的.then() 块并更改...

modal.element.modal;     // -- nothing

modal.element.modal();  // -- fn call

JSFiddle Link - 演示

【讨论】:

    猜你喜欢
    • 2016-08-08
    • 2019-06-03
    • 1970-01-01
    • 1970-01-01
    • 2015-06-26
    • 2014-06-27
    • 2022-07-12
    • 2017-12-22
    • 1970-01-01
    相关资源
    最近更新 更多