showing results for - "angular get device information"
Baptiste
01 Jan 2019
1
2npm install ngx-device-detector
3
Larry
16 Aug 2018
1
2import { Component, VERSION } from "@angular/core";
3import { DeviceDetectorService } from "ngx-device-detector";
4
5@Component({
6  selector: "my-app",
7  templateUrl: "./app.component.html",
8  styleUrls: ["./app.component.css"]
9})
10export class AppComponent {
11  name = "Angular " + VERSION.major;
12  deviceInfo = null;
13  isDesktopDevice: boolean;
14  isTablet: boolean;
15  isMobile: boolean;
16
17  constructor(private deviceService: DeviceDetectorService) {
18    this.epicFunction();
19  }
20
21  epicFunction() {
22    this.deviceInfo = this.deviceService.getDeviceInfo();
23    this.isMobile = this.deviceService.isMobile();
24    this.isTablet = this.deviceService.isTablet();
25    this.isDesktopDevice = this.deviceService.isDesktop();
26  }
27}
28