A simple angularJs service to detect platform, browser and version
live demo here
You can directly clone/download here
git clone git@github.com:sibiraj-s/ng-browser-detector.gitor use cdn
Minified:
//cdn.jsdelivr.net/npm/ng-browser-detector@latest/ng-browser-detector.min.jsPretty Printed:
//cdn.jsdelivr.net/npm/ng-browser-detector@latest/ng-browser-detector.jsor
Install via Package managers such as npm or yarn
npm install ng-browser-detector --save
# or
yarn add ng-browser-detectorImport 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