ng-browser-detector demo



You are viewing this page in {{browserInfo.name}} - {{browserInfo.version}} (v-{{browserInfo.platform}})

ng-browser-detector

Installation

Installation can be done via package managers such as npm or yarn


  npm install ng-browser-detector --save
  # or
  yarn add ng-browser-detector
  

Usage

import the modules required for ng-browser-detector.


  <script src="angular/angular.min.js"></script>
  <script src="../ng-browser-detector.min.js"></script>
      

add the ngBrowser dependency to the module


  angular.module('myApp', ['ngBrowser'])
      

in your controller


  app.controller('mainController', ['$scope', 'appBrowser', function($scope, appBrowser) {
     $scope.appBrowser = appBrowser;
  }]);
      

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 detauls are added as attributes