Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 方向改变不';我不能在有角度的地方工作_Angularjs_Angularjs Directive - Fatal编程技术网

Angularjs 方向改变不';我不能在有角度的地方工作

Angularjs 方向改变不';我不能在有角度的地方工作,angularjs,angularjs-directive,Angularjs,Angularjs Directive,我试图检查角度方向改变的工作,但它不起作用 var myApp = angular.module('myApp',['ngTouch','matchmedia-ng']); function checkOrientation($scope){ if($scope.landscape){ $scope.isLandscape="landscape"; alert($scope.isLandscape); } else{ $s

我试图检查角度方向改变的工作,但它不起作用

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()选项,但它也不起作用。它可以工作,但当我改变方向时就不行了

在checkOrientation中,您只需查看以下值即可查看您所处的方向:

$window.screen.orientation.type