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