JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2707
  • Score
    100M100P100Q147652F
  • License ISC

<a href="https://koderlabs.github.io/ngx-device-detector"> <h1 align="center">angular-device-detector</h1> </a>

Package Exports

  • angular-device-information
  • angular-device-information/bundles/angular-device-information.umd.js
  • angular-device-information/fesm5/angular-device-information.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (angular-device-information) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

angular-device-detector

Installation

To install this library, run:

$ npm install angular-device-detector --save

In your app.module.ts file add DeviceInformationDetectorService as providers

  import { NgModule } from '@angular/core';
  import { BrowserModule } from '@angular/platform-browser';
  import { FormsModule } from '@angular/forms';
  
  import { AppComponent } from './app.component';
  import { DeviceInformationDetectorService } from 'angular-device-detector';
  
  @NgModule({
    imports:      [ BrowserModule, FormsModule ],
    providers:[AngularDeviceInformationService],
    declarations: [ AppComponent ],
    bootstrap:    [ AppComponent ]
  })
  
**In your component where you want to use the Device Service**
 
 import { Component } from '@angular/core';
 ...
 import { AngularDeviceInformationService } from 'angular-device-information';
 ...
 @Component({
   selector: 'home',  // <home></home>
   styleUrls: [ './home.component.scss' ],
   templateUrl: './home.component.html',
   ...
 })

 export class HomeComponent {
   deviceInfo = null;
   ...
   constructor(private http: Http, private deviceInformationService: AngularDeviceInformationService) {
 
            console.log(deviceInformationService.isMobile());  // returns if the device is a mobile device (android / iPhone / windows-phone etc)
            console.log(deviceInformationService.isTablet());  // returns if the device us a tablet (iPad etc)
            console.log(deviceInformationService.isDesktop()); // returns if the app is running on a Desktop browser.
            console.log(deviceInformationService.getDeviceType()); // returns if the app is running on a Desktop browser.
            console.log(deviceInformationService.getDeviceInfo().os);  // returns os name
            console.log(deviceInformationService.getDeviceInfo().osVersion);  // returns os version
            console.log(deviceInformationService.getDeviceInfo().browser);  // returns browser name
            console.log(deviceInformationService.getDeviceInfo().browserVersion);  // returns browser version
            console.log(deviceInformationService.getDeviceInfo().browserMajorVersion);  // returns full browser version
            console.log(deviceInformationService.getDeviceInfo().screen_resolution);  // returns screnn size
            console.log(deviceInformationService.getDeviceInfo().cookies);  // returns cookies enabled or no 
            console.log(deviceInformationService.getDeviceInfo().userAgent);  // returns userAgent
   }
   
 }

```