【发布时间】: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