0

I am trying to calculate the window width on orientation change for android devices using jquery function $(window).outerWidth(true);. This calculation gives correct width on orientation change for both iphone and ipad but not in android. If i initially load the page in landscape mode or portrait mode i am getting the correct width but once i change the orientation after loading the page i am getting the width for portrait mode as was in landscape mode and vice versa. Please suggest what is happening and how can i handle this issue so that i get the correct window width on orientation change in android device.

I'm trying to solve with this post How to get the correct window width on orientation change for android devices both tablets and mobiles , but anything is working for me.

@user850234 any idea? Thanks in advance.

2
  • Instead of using the JavaScript window object, try using the angular $window . docs.angularjs.org/api/ng/service/$window Commented Dec 14, 2015 at 15:58
  • Thanks for your answer, but it's not working. I have the same issue. Any idea? Commented Dec 15, 2015 at 16:19

1 Answer 1

0

Try using the 'orientationchange' event and the $window service (dont forget to inject $window)

In the angular.run() function, add the following event listener

 angular.element($window).bind('orientationchange', function () { var width = $window.innerWidth; }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.