This module allows you to detect iOS, Android and Windows Phone devices using user agent string
Check out http://www.janantala.com/slides/how-to-build-an-open-source-angularjs-module/#/7/4
- AngularJS v 1.2.x+
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) {
}]);
You can configure provider to a custom User Agent string in app configuration.
$detectionProvider.setUserAgent('angular browser');
You can detect Android and iOS devices using:
$detection.isAndroid();
$detection.isiOS();
$detection.isWindowsPhone();
Contributions are welcome. Please make a pull request against canary branch and do not bump versions. Also include tests.
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
The MIT License
Copyright (c) 2014 Jan Antala