# Orientation Screen

**URL:** <https://forum.ionicframework.com/t/orientation-screen/27612>\
**Category:** ionic-v1\
**Created:** [July 3, 2015, 9:11am UTC](https://forum.ionicframework.com/t/orientation-screen/27612 "2015-07-03T09:11:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cantagrel](https://avatars.discourse-cdn.com/v4/letter/c/73ab20/32.png) [@Cantagrel](https://forum.ionicframework.com/u/Cantagrel)\
**Post date:** [July 3, 2015, 9:11am UTC](https://forum.ionicframework.com/t/orientation-screen/27612/1 "2015-07-03T09:11:48Z")

</div>

Hello,  
I want to change the state if the orientation is in landscape or portrait.  
Any issue on ionic to detect the orientation screen ?  
Best regards

---

<div class="post-metadata">

**Author:** ![pliablepixels](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/pliablepixels/32/112372_2.png) [@pliablepixels](https://forum.ionicframework.com/u/pliablepixels)\
**Post date:** [July 3, 2015, 2:05pm UTC](https://forum.ionicframework.com/t/orientation-screen/27612/2 "2015-07-03T14:05:05Z")

</div>

When building my app, I found this method to be the most reliable of the lot

```auto
    // this works reliably on both Android and iOS. The "onorientation" seems to reverse w/h in Android. Go figure.
    // http://stackoverflow.com/questions/1649086/detect-rotation-of-android-phone-in-the-browser-with-javascript

    var checkOrientation = function () {
        var pixelRatio = window.devicePixelRatio || 1;
        $rootScope.devWidth = ((window.innerWidth > 0) ? window.innerWidth : screen.width);
        $rootScope.devHeight = ((window.innerHeight > 0) ? window.innerHeight : screen.height);
        console.log(" ******** NEW Computed Dev Width & Height as" + $rootScope.devWidth + "*" + $rootScope.devHeight);
  
    };

    window.addEventListener("resize", checkOrientation, false);

```
