diff --git a/.playground/index.js b/.playground/index.js new file mode 100644 index 0000000..4035c62 --- /dev/null +++ b/.playground/index.js @@ -0,0 +1,80 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * This is only for local test + */ +var platform_browser_1 = require("@angular/platform-browser"); +var core_1 = require("@angular/core"); +var core_2 = require("@angular/core"); +var platform_browser_dynamic_1 = require("@angular/platform-browser-dynamic"); +var core_3 = require("@angular/core"); +var dist_1 = require("../dist"); +var KeysPipe = (function () { + function KeysPipe() { + } + KeysPipe.prototype.transform = function (value, props) { + if (props === void 0) { props = []; } + var keys = []; + var noFilter = props.length === 0; + for (var key in value) { + if (noFilter) { + if (value.hasOwnProperty(key)) { + keys.push({ key: key, value: value[key] }); + } + } + else { + if (props.indexOf(key) !== -1) { + keys.push({ key: key, value: value[key] }); + } + } + } + return keys; + }; + KeysPipe = __decorate([ + core_3.Pipe({ + name: 'keys' + }) + ], KeysPipe); + return KeysPipe; +}()); +exports.KeysPipe = KeysPipe; +var AppComponent = (function () { + function AppComponent(deviceService) { + this.deviceService = deviceService; + this.propsToShow = ["userAgent", "os", "browser", "device", "os_version", "browser_version"]; + this.device = null; + this.device = deviceService.getDeviceInfo(); + console.log(this.device); + } + AppComponent = __decorate([ + core_2.Component({ + selector: 'app', + template: "\n
\n Open this page from different devices to see the appropriate details\n
\nProperty | \nValue | \n
---|---|
{{info.key}} | \n{{info.value}} | \n
+An Angular 2 (and beyond) powered AOT compatible device detector that helps to identify browser, os and other useful information regarding the device using the app. The processing is based on user-agent. +
+ -> An Angular 2 (and beyond) powered AOT compatible device detector that helps to identify browser, os and other useful information regarding the device using the app. The processing is based on user-agent. - -## Breaking changes in 1.0.0 -The module name and the service name has been changed. See the Usage and Change Log sections below ## Live DEMO -[Ng2 Device Detector Demo](https://koderlabs.github.io/ng2-device-detector) - +[Ngx Device Detector Demo](https://koderlabs.github.io/ngx-device-detector) ## Installation @@ -23,14 +26,14 @@ The module name and the service name has been changed. See the Usage and Change To install this library, run: ```bash -$ npm install ng2-device-detector --save +$ npm install ngx-device-detector --save ``` ## Usage -Import `Ng2DeviceDetectorModule` in your app.module.ts +Import `DeviceDetectorModule` in your app.module.ts ```bash import { NgModule } from '@angular/core'; - import { Ng2DeviceDetectorModule } from 'ng2-device-detector'; + import { DeviceDetectorModule } from 'ngx-device-detector'; ... @NgModule({ declarations: [ @@ -42,7 +45,7 @@ Import `Ng2DeviceDetectorModule` in your app.module.ts imports: [ CommonModule, FormsModule, - Ng2DeviceDetectorModule.forRoot() + DeviceDetectorModule.forRoot() ], providers:[ AuthService @@ -55,7 +58,7 @@ In your component where you want to use the Device Service ```bash import { Component } from '@angular/core'; ... - import { Ng2DeviceService } from 'ng2-device-detector'; + import { DeviceDetectorService } from 'ngx-device-detector'; ... @Component({ selector: 'home', //Open this page from different devices to see the appropriate details @@ -10,12 +10,27 @@