Angular的退出全屏,全屏显示以及关闭系统

html中的代码:
 
<li class="dropdown" id="dropdown4">
    <a href="#"  class="dropdown-toggle" data-toggle="dropdown" ng-bind="window"><b class="caret"></b></a>
    <ul class="dropdown-menu" ng-controller="screen">
        <li id="view-fullscreen">
            <a href="#"  ng-click="fullScreen()">全屏显示</a>
        </li>
        <li class="divider"></li>
        <li id="cancel-fullscreen">
            <a href="#" ng-click="exitScreen()">退出全屏</a>
        </li>
        <li class="divider"></li>
        <li id="sytemExit">
            <a href="#" ng-click="systemClose()">关闭窗口</a>
        </li>
    </ul>
</li>

 

angularjs的代码:
var apiGatewayCtrls = angular.module('apiGatewayCtrls', ['ionic']);
apiGatewayCtrls.controller('screen',function ($scope,$window) {
    $scope.fullScreen = function () {
        var viewFullScreen = document.getElementById("view-fullscreen");
        if (viewFullScreen) {
            viewFullScreen.addEventListener("click", function () {
                var docElm = document.documentElement;
                if (docElm.requestFullscreen) {
                    docElm.requestFullscreen();
                }
                else if (docElm.msRequestFullscreen) {
                    docElm = document.body; //overwrite the element (for IE)
                    docElm.msRequestFullscreen();
                }
                else if (docElm.mozRequestFullScreen) {
                    docElm.mozRequestFullScreen();
                }
                else if (docElm.webkitRequestFullScreen) {
                    docElm.webkitRequestFullScreen();
                }
            }, false);
        }
    }
    $scope.exitScreen = function () {
        var cancelFullScreen = document.getElementById("cancel-fullscreen");
        if (cancelFullScreen) {
            cancelFullScreen.addEventListener("click", function () {
                if (document.exitFullscreen) {
                    document.exitFullscreen();
                }
                else if (document.msExitFullscreen) {
                    document.msExitFullscreen();
                }
                else if (document.mozCancelFullScreen) {
                    document.mozCancelFullScreen();
                }
                else if (document.webkitCancelFullScreen) {
                    document.webkitCancelFullScreen();
                }
            }, false);
        }
    }
    $scope.systemClose = function () {
        var sytemExit = document.getElementById("sytemExit");
        if (sytemExit) {
            sytemExit.addEventListener("click", function () {
                if (confirm("您确定要关闭本系统吗?")) {
                    $window.close();
                }
                else {
                }
            })
        }
    }
});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值