This module allows you to detect iOS, Android and Windows Phone devices using user agent string
Switch branches/tags
Pull request Compare This branch is 11 commits behind angular-adaptive:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.bowerrc
.gitignore
.jshintrc
.travis.yml
CHANGELOG.md
LICENSE
README.md
angular-adaptive-detection.min.js
bower.json
gulpfile.js
karma.conf.js
package.json

README.md

adaptive-detection v0.3.0 Build Status

This module allows you to detect iOS, Android and Windows Phone devices using user agent string

Demo

Check out http://www.janantala.com/slides/how-to-build-an-open-source-angularjs-module/#/7/4

Requirements

  • AngularJS v 1.2.x+

Usage

We use bower for dependency management. Add

"dependencies": {
    "angular-adaptive-detection": "latest"
}

To your bower.json file. Then run

bower install

This will copy the angular-adaptive-detection files into your bower_components folder, along with its dependencies. Load the script files in your application:

<script type="text/javascript" src="bower_components/angular/angular.js"></script>
<script type="text/javascript" src="bower_components/angular-adaptive-detection/angular-adaptive-detection.min.js"></script>

Add the adaptive.detection module as a dependency to your application module:

var myAppModule = angular.module('MyApp', ['adaptive.detection']);

and include $detection provider as a dependency to your controller:

angular.module('MyApp').controller('MainCtrl', function ['$scope', '$detection', ($scope, $detection) {

}]);

Configuration

You can configure provider to a custom User Agent string in app configuration.

$detectionProvider.setUserAgent('angular browser');

Public methods

You can detect Android and iOS devices using:

    $detection.isAndroid();
    $detection.isiOS();
    $detection.isWindowsPhone();

Contributing

Contributions are welcome. Please make a pull request against canary branch and do not bump versions. Also include tests.

Testing

We use karma and jshint to ensure the quality of the code. The easiest way to run these checks is to use grunt:

npm install -g grunt-cli
npm install
bower install
grunt

The karma task will try to open Chrome as a browser in which to run the tests. Make sure this is available or change the configuration in test/test.config.js

License

The MIT License

Copyright (c) 2014 Jan Antala