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