在角度模态控制器中通过示波器时,未显示第二次

问题描述 投票:1回答:1

我正在从控制器中调用模式弹出窗口。第一次可以正常运行,但第二次不显示。这是该节目的代码

$scope.showAdvanced = function (ev) {
    var scopeVar = $scope;
    console.log('$mdDialog');
    console.log($mdDialog);
    $mdDialog.show({
        controller: DialogController,
        templateUrl: 'dialog1.tmpl.html',
        parent: angular.element(document.body),
        scope: $scope,
        targetEvent: ev,
        clickOutsideToClose: true
    }).then(function (result) {

        //$scope = $scope.$parent;
        console.log($scope);
    });

};

这是我在DialogController中的hide函数。

   $scope.hide = function () {
    console.log('hide called');
    $mdDialog.hide();
    console.log('hide completed');

};

隐藏成功执行,然后在show中定义回调,该回调将打印当前范围。如果我删除scope:$ scope并放入transclude:true,则尽管您可以多次显示和隐藏它,但它不会在对话框控制器中显示数据。

angularjs angularjs-material
1个回答
4
投票

preserveScope: true添加到模态选项。对话会删除其默认关闭范围。

© www.soinside.com 2019 - 2024. All rights reserved.