Git Product home page Git Product logo

angular-device-information's Introduction

angular-device-information

Dependencies

Angular Version
Angular 8+ v 1.1.5
Angular 14.x v 2.0.1
Angular 15.x v 3.0.5

Support us :

Installation

To install this library, run:

$ npm install angular-device-information --save

NPM LINK : https://www.npmjs.com/package/angular-device-information

In your app.module.ts file add AngularDeviceInformationService as providers(Optional)

  import { NgModule } from '@angular/core';
  import { BrowserModule } from '@angular/platform-browser';
  import { FormsModule } from '@angular/forms';
  
  import { AppComponent } from './app.component';
  import { AngularDeviceInformationService } from 'angular-device-information';
  
  @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 {
 
   constructor(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 is a tablet (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 like Windows/Andtoid/iOS/Linux/Mac OS X etc
      console.log(deviceInformationService.getDeviceInfo().osVersion);  // returns os version like 10/8.1/7 ...etc
      console.log(deviceInformationService.getDeviceInfo().browser);  // returns browser name like chrome/firefox ...etc
      console.log(deviceInformationService.getDeviceInfo().browserVersion);  // returns browser version as number
      console.log(deviceInformationService.getDeviceInfo().browserMajorVersion);  // returns full browser version as number
      console.log(deviceInformationService.getDeviceInfo().screen_resolution);  // returns screnn size like 1390x860/640x800 ...etc
      console.log(deviceInformationService.getDeviceInfo().cookies);  // returns cookies enabled or no 
      console.log(deviceInformationService.getDeviceInfo().userAgent);  // returns userAgent
   }
   
 }

License

MIT

angular-device-information's People

Contributors

becher avatar

Watchers

 avatar

Forkers

vierlijner

angular-device-information's Issues

Dependency resolution doesn't work with non v9 Angular

I'm on Angular 14.1.1 and when I try to npm install this package, I get an npm error that the dependency @angular/common@"^9.1.13" could not be resolved.

Similar packages that support multiple versions of Angular have been branched to release for specific versions of Angular, with any bug fixes from master being merged/cherry-picked out to the various Angular-version branches. Then, multiple versions of the package are released to npm, one for each targeted version of Angular.

Furthermore, it appears that for compatibility's sake, this is still a View Engine library. It would be great to get an Ivy distribution for the versions of Angular that support it. During an ng build, I get the following output:
⠹ Generating browser application bundles (phase: setup)...Processing legacy "View Engine" libraries:
- angular-device-information [es2015/esm2015] (git+https://github.com/becher/angular-device-information.git)
Encourage the library authors to publish an Ivy distribution.

I'm not sure if that's too much work for this project, but figured it was worth a request. I can force the install for now and get it to work, but it's definitely not ideal since every developer on the team has to do the same.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.