【问题标题】:Angular Material Pre rendered Dialog IssueAngular 材质预渲染对话框问题
【发布时间】: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 版本。之后就可以正常工作了

标签: angularjs material-design


【解决方案1】:

因此,正如 Vishal 指出的,您需要使用最新版本的角材料。就我而言,1.1.0-RC2 还不够。我切换到 1.1.0-RC5,一切正常。

最新版本可以在这里找到:https://developers.google.com/speed/libraries/#angular-material

【讨论】:

    猜你喜欢
    • 2020-12-30
    • 1970-01-01
    • 2022-10-13
    • 2021-08-22
    • 2019-09-16
    • 2020-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多