2014-04-21 71 views
0

在我的主控制器,我已經得到了切換真/假的全屏瀏覽器狀態,像這樣的功能:角和HTML5全屏API

// Full Screen toggle 
$scope.fsState = false; 
$scope.fullScreen = function fullScreen(){ 
    function launchFS(element) { 
    if (element.requestFullScreen) element.requestFullScreen(); 
    else if (element.mozRequestFullScreen) element.mozRequestFullScreen(); 
    else if (element.webkitRequestFullScreen) element.webkitRequestFullScreen(); 
    } 
    function cancelFS() { 
    if (document.cancelFullScreen) document.cancelFullScreen(); 
    else if (document.mozCancelFullScreen) document.mozCancelFullScreen(); 
    else if (document.webkitCancelFullScreen) document.webkitCancelFullScreen(); 
    } 
    if($scope.fsState == false) launchFS(document.documentElement); 
    else cancelFS(); $scope.fsState = !$scope.fsState; 
}; 

並在視圖...

<button class="btn" ng-click="fullScreen()">Toggle Fullscreen</button> 

這工作正常,除了當我導航到SPA內的另一頁。每次我從主導航菜單(也在同一個控制器中)進行選擇時,頁面會跳出全屏。任何想法爲什麼Angular.js正在這樣做,或者可以做什麼,所以它維護路線變化之間的狀態?

回答

0

您可能會刪除全屏元素並讀取它。它應該是在你的用戶界面視圖的頂部,像

<body> 
    <div class="fullscreen-container"> 
    <div ui-view></div> 
    </div> 
</body> 

您也可以使用這個項目,以避免調用供應商特定功能 https://github.com/hrajchert/angular-screenfull