首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >让ng-show与Html5 <dialog>元素一起工作

让ng-show与Html5 <dialog>元素一起工作
EN

Stack Overflow用户
提问于 2016-07-07 19:41:28
回答 0查看 231关注 0票数 0

Html5对话框很简单。15年前就该去那儿了!

如何让ng-show与对话框一起工作(它不工作)?

代码语言:javascript
复制
<!DOCTYPE html>
<html ng-app="project">
<head>
    <meta charset='UTF-8'>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.7/angular.min.js"></script>
    <script>
        angular.module('project', [])
                .controller('TheController', function ($scope) {
                    $scope.dialogShowing = false;
                    $scope.showDialog = function () {
                        dialogShowing = true;
                        document.getElementById('theDialog').show();
                    };
                    $scope.hideDialog = function () {
                        dialogShowing = false;
                        document.getElementById('theDialog').close();
                    };
                });
    </script>
</head>
<body ng-controller="TheController">
<div> Hello
    <!-- dialog, where it is placed in the source, doesn't take up space -->
    <dialog id="theDialog">
        <div>
            <h3>Simple Angular Html5Dialog</h3>
            <hr/>
            <p>I am very well, thank you</p>
            <button ng-click="hideDialog()">No, thank you</button>
        </div>
    </dialog>
    how are you?
</div>
<button ng-click="showDialog()">^ Click for the answer</button>
</body>
</html>

我唯一能够运行的就是对话框小部件本身上的.open()和.close(),并且必须模拟上面的ng-show/hide。

建议?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38244562

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档