A simple angularJs service to detect platform, browser and version
live demo here
You can directly clone/download here
git clone [email protected]:sibiraj-s/ng-browser-detector.git
or use cdn
Minified:
//cdn.jsdelivr.net/npm/ng-browser-detector@latest/ng-browser-detector.min.js
Pretty Printed:
//cdn.jsdelivr.net/npm/ng-browser-detector@latest/ng-browser-detector.js
or
Install via Package managers such as npm or yarn
npm install ng-browser-detector --save
# or
yarn add ng-browser-detector
Import the modules required for ng-browser-detector.
<-- scripts -->
<script src="angular/angular.min.js"></script>
<script src="../ng-browser-detector.min.js"></script>
add ngBrowser
dependency to the module
angular.module('myApp', ['ngBrowser'])
in routes config
app.controller('mainController', ['$scope', 'appBrowser', function($scope, appBrowser) {
$scope.appBrowser = appBrowser;
appBrowser.getPlatform();
}]);
to get platform
appBrowser.getPlatform();
to get browser name
appBrowser.getName();
to get browser version
appBrowser.getVersion();
a simple directive is included (usage : optional)
<body browser-detector></body>
the directive appends the browser details to element's class, if provided browser-detector="attr"
then the details are added as attributes