Javascript 角度材质$mdDialog.hide()不起作用

Javascript 角度材质$mdDialog.hide()不起作用,javascript,angularjs,angular-material,mddialog,Javascript,Angularjs,Angular Material,Mddialog,我在用有棱角的材料工作。我正在使用$mdDialog在我的应用程序上创建一个弹出窗口。除了$mdDialog.hide()不起作用外,其他一切都正常 $ctrl.footerModal = function () { $mdDialog.show({ template: '<md-dialog aria-label="Privacy Policy">' + '<md-dialo

我在用有棱角的材料工作。我正在使用$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();
            };
        }
$ctrl.footerModal=函数(){
$mdDialog.show({
模板:“”+
'' +
'' +
“隐私政策”+
“sum自16世纪以来一直是行业标准的虚拟文本,当时一台不知名的打印机”+
“拿了一个刻字的厨房,把它拼凑成一本刻字样本书。它不仅保存了五个世纪。”+
“但也有向电子排版的飞跃,基本上保持不变。它在20世纪60年代流行”+
“随着包含Lorem Ipsum段落的Letraset表单的发布,以及最近的desk发布

”+ “”+ '' + '' + '' + '' + '' + '' + “好的”+ '' + '' + '', 父元素:angular.element(document.body), 单击外部以关闭:true }); $ctrl.cancel=函数(){ $mdDialog.hide(); }; }

有人能告诉我我做错了什么吗

你应该使用
.hide

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

您的
$ctrl.cancel
功能应如Ramesh所述放置在外部


请在
$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();
         };
$ctrl.footerModal=函数(){
$mdDialog.show({
模板:“”+
'' +
'' +
“隐私政策”+
“sum自16世纪以来一直是行业标准的虚拟文本,当时一台不知名的打印机”+
“拿了一个刻字的厨房,把它拼凑成一本刻字样本书。它不仅保存了五个世纪。”+
“但也有向电子排版的飞跃,基本上保持不变。它在20世纪60年代流行”+
“随着包含Lorem Ipsum段落的Letraset表单的发布,以及最近的desk发布

”+ “”+ '' + '' + '' + '' + '' + '' + “好的”+ '' + '' + '', 父元素:angular.element(document.body), 单击外部以关闭:true }); } $ctrl.cancel=函数(){ $mdDialog.hide(); };
你在哪里使用了
$mdDialog.hide()
?我已经更新了代码。他也在使用这个same@RameshRajendran不,他在用。取消,现在他已经编辑了。我有评论。请更新OP更新问题的答案。我取下我的衣服vote@RameshRajendran你能检查一下我提供的演示吗?