1

私は角度のある素材を扱っています。$mdDialog を使用して、アプリケーションにポップアップを作成しています。$mdDialog. hide() が機能しないことを除いて、すべて正常に機能します。

       $ctrl.footerModal = function () {
            $mdDialog.show({
                template: '<md-dialog aria-label="Privacy Policy">' +
                '<md-dialog-content>' +
                '<div class="md-dialog-content">' +
                '<h2>Privacy Policy</h2>' +
                '<p> sum has been the industrys standard dummy text ever since the 1500s, when an unknown printer ' +
                'took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, ' +
                'but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s ' +
                ' with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desk</p>' +
                '<p>' +
                '</div>' +
                '</md-dialog-content>' +
                '<md-dialog-actions layout="row">' +
                '<span flex>' + '</span>' +
                '<md-button ng-click="$ctrl.cancel()">' +
                'Ok' +
                '</md-button>' +
                '</md-dialog-actions>' +
                '</md-dialog>',
                parent: angular.element(document.body),
                clickOutsideToClose: true
            });
            $ctrl.cancel = function () {
                $mdDialog.hide();
            };
        }

ここで私が間違っていることを誰かに教えてもらえますか

4

2 に答える 2

1

を使用する必要があります.hide

$scope.cancel = function() {
   $mdDialog.hide();
};

編集:

Ramesh$ctrl.cancelが述べたように、関数は外部に配置する必要があります

デモ

于 2016-11-16T10:56:08.000 に答える
1

$ctrl.footerModal関数の外にコードを書いてください。

あなたのコードは

$ctrl.footerModal = function () {
            $mdDialog.show({
                template: '<md-dialog aria-label="Privacy Policy">' +
                '<md-dialog-content>' +
                '<div class="md-dialog-content">' +
                '<h2>Privacy Policy</h2>' +
                '<p> sum has been the industrys standard dummy text ever since the 1500s, when an unknown printer ' +
                'took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, ' +
                'but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s ' +
                ' with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desk</p>' +
                '<p>' +
                '</div>' +
                '</md-dialog-content>' +
                '<md-dialog-actions layout="row">' +
                '<span flex>' + '</span>' +
                '<md-button ng-click="cancel()">' +
                'Ok' +
                '</md-button>' +
                '</md-dialog-actions>' +
                '</md-dialog>',
                parent: angular.element(document.body),
                clickOutsideToClose: true
            });
         }

 $ctrl.cancel = function () {
             $mdDialog.hide();
         };
于 2016-11-16T11:03:22.180 に答える