Uses user-agent to set css classes or directly usable via JS.
npm install ng-device-detector









Uses user-agent to set CSS classes or directly usable via JS.
See website: http://srfrnk.github.io/ng-device-detector
sh
$ npm install ng-device-detector --save
`
Bower
`sh
$ bower install ng-device-detector --save
`
Browser (Add scripts in HTML)
`sh
`
Adding 'ng.deviceDetector' to your app module dependencies
`js
angular.module('app', ['ng.deviceDetector']);
`
Injecting DeviceDetector service in controller
`js
angular.module('app').controller('Home', function($scope, deviceDetector){
// Awesome stuff
});
`To add classes, add directive like:
$3
You can set custom detectors at the provider object.
The
`javascript
angular.module('app', ["ng.deviceDetector"])
.config(['deviceDetectorProvider', function(deviceDetectorProvider) {
deviceDetectorProvider.addCustom("Custom_UA_Entry", {
and:["\\bCustom_UA_Entry\\b", {
not:"\\bChrome\\b"
}]
});
}])
.controller('Home', function($scope, deviceDetector) {
// (true / false)
$scope.customUAEntry = deviceDetector.custom["Custom_UA_Entry"];
});
``> Custom detectors will also be added as CSS classes with 'is-' prefix and encoded into css class name casing.
Pull-requests with new stuff will be highly appreciated :)
See plunker