2015-01-20 2 views
0

방향 변경 작업 을 확인하려고하는데 각도가인데 작동하지 않습니다.각도 변경이 각도에서 작동하지 않습니다.

var myApp = angular.module('myApp',['ngTouch','matchmedia-ng']); 

function checkOrientation($scope){ 
    if($scope.landscape){ 
     $scope.isLandscape="landscape"; 
     alert($scope.isLandscape); 
    } 
    else{ 
     $scope.isLandscape="portrait"; 
     alert($scope.isLandscape); 
    } 
} 

myApp.controller('MainController', ['$scope', '$window','matchmedia', 
    function($scope, $window, matchmedia) { 
    $scope.submit = function() { 
     alert("submitted!"); 
    } 
    $scope.desktop = matchmedia.isDesktop(); 
    $scope.tablet =matchmedia.isTablet(); 
    $scope.phone = matchmedia.isPhone(); 
    $scope.landscape = matchmedia.isLandscape(); 

     if($scope.desktop){ 
      alert("desktop"); 
     } 
     else if($scope.tablet){ 
      alert("tablet"); 
     } 
     else if($scope.phone){ 
      $scope.isDevice = 'phone'; 
     } 

     checkOrientation($scope); 

     /*screen.bind('orientationchange', function() { 
      $route.reload(); 
     });*/ 
     angular.element($window).bind('orientationchange', function ($scope) { 
      checkOrientation($scope); 
     }); 
}]); 

$ route.reload() 옵션도 시도했지만 작동하지 않습니다. 그것은 작동하지만 내가 방향을 바꿀 때 작동하지 않습니다.

답변

0

checkOrientation에서 당신은 단지의 값에 볼 수 있습니다 당신이있어 어떤 방향을보고 다음

$window.screen.orientation.type 
관련 문제