【发布时间】:2016-10-17 13:54:44
【问题描述】:
我正在尝试使用预渲染对话框,但我认为存在某种错误。
我已经使用 HTML 作为
<div style="visibility: hidden">
<div class="md-dialog-container" id="myDialog">
<md-dialog layout-padding="" aria-label="myDialog">
<h2>Pre-Rendered Dialog</h2>
<p>
This is a pre-rendered dialog, which means that <code>$mdDialog</code> doesn't compile its
template on each opening.
<br><br>
The Dialog Element is a static element in the DOM, which is just visually hidden.<br>
Once the dialog opens, we just fetch the element from the DOM into our dialog and upon close
we restore the element back into its old DOM position.
</p>
</md-dialog>
</div>
</div>
我的 JAvascript 也包含以下代码
$scope.showPrerenderedDialog = function (ev) {
$mdDialog.show({
controller: DialogController,
contentElement: '#myDialog',
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true
});
};
function DialogController($scope, $mdDialog) {
$scope.hide = function () {
$mdDialog.hide();
};
$scope.cancel = function () {
$mdDialog.cancel();
};
$scope.answer = function (answer) {
$mdDialog.hide(answer);
};
}
有什么帮助吗?
【问题讨论】:
-
您是否在控制台中遇到任何错误?或者发生了什么,对话框没有打开,它静默失败还是什么?
-
我也有同样的问题。你搞清楚了吗?
-
是的,我已经想通了。您需要添加最新版本的角材料,即 RC 版本。之后就可以正常工作了