How can I get rotation/tilt value of phone

Hey guys,

just wanted to ask how I can get the value (in degree) of my phone if im rotating / tilting it?

Where to start, what to use?

You want the device orientation APIs:

Try to use ionic creator then over you will find a orientation icon , which will help to understand how device will look on tilt , it will help us to design application more responsive

Hey,

thank you for the link. I’ve already tried that and can’t get the right values.

here’s my app:

I need the value of the phone tilt LEFT and RIGHT when the display is facing the user. Everything else should be ignored.
Also the values should only range from 0 to 90 degree.

If I’m using the basic example from mozilla I get the following numbers at ~45degree (phone display facing the user)

function handleOrientation(event) {
  var absolute = event.absolute;
  var a    = event.alpha;
  var x     = event.beta;
  var y    = event.gamma;

  $scope.absolute = absolute;
  $scope.a = a;
  $scope.b = x;
  $scope.g = y;
}

image