Angular-modal-service does not show modal

Angular-modal-service does not show modal

本文关键字:modal show not does Angular-modal-service      更新时间:2023-09-26

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

策略在/cookiepolicy上。选中了,这个链接工作得很好。

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

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

因为我只想为url调用modal,所以html中没有添加任何其他内容。

调用modal的函数(也会在最后一行被调用并报告成功)

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!");
});

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

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

modal.element.modal;     // -- nothing

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

JSFiddle Link - demo