I try to hide / show certain things when the orientation of the phone changes.
Here is my view:
<div ng-controller="ModelCtrl">
<p ng-show="isLandscape">Landscape - {{ isLandscape }}</p>
<p ng-show="!isLandscape">Portrait - {{ !isLandscape }}</p>
</div>
And here is the controller fragment:
$scope.isLandscape = false;
window.addEventListener("orientationchange", function() {
switch(window.orientation)
{
case -90:
case 90:
$scope.isLandscape = true;
alert($scope.isLandscape);
break;
default:
$scope.isLandscape = false;
alert($scope.isLandscape);
break;
}
}, false);
I can warn the correct value of isLandscape when the orientation changes, but it seems that it does not update the view, so it always says this in "portrait mode - true".
source
share