Angular Material Pre渲染对话框问题

时间:2016-06-16 07:27:33

标签: angularjs material-design

我正在尝试使用预呈现的对话框,但我认为存在某种错误。

我使用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);
        };
    }

任何帮助?

1 个答案:

答案 0 :(得分:0)

正如Vishal指出的那样,你需要最新版本的角度材料。就我而言,1.1.0-RC2还不够。我切换到1.1.0-RC5,一切都按预期工作。

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