Samantha J Samantha J - 10 months ago 34
AngularJS Question

How can I set a variable in $rootscope to show if a browser is running on an iPad?

I know there are some libraries that can do this but I would like to do something as simple as possible and I didn't see any examples that were for an AngularJS app. The problem is I do not know where to start.

Can someone give me some advice or point me in the right direction.


  .module('test', [])
  .run(function($rootScope) {
    $rootScope.isIpad = /ipad/i.test(navigator.userAgent);
<script src=""></script>

<section ng-app="test">
  <h1>is iPad? <span ng-bind="isIpad | json"></span></h1>

if you want to have a more robust solution, have a look here Detect iPad users using jQuery?