npm i ngx-sharebuttons
app.component.ts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
import { Component, VERSION } from '@angular/core'; import { DeviceDetectorService } from 'ngx-device-detector'; @Component({ selector: 'my-app', templateUrl: './app.component.html' }) export class AppComponent { constructor(private deviceService: DeviceDetectorService) {} get device(): any { return this.deviceService.getDeviceInfo(); } get isMobile(): boolean { return this.deviceService.isMobile(); } get isTablet(): boolean { return this.deviceService.isTablet(); } get isDesktop(): boolean { return this.deviceService.isDesktop(); } } |
app.component.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<div class="container mt-5"> <div> <h1>Device Info:</h1> <pre>{{ device | json }}</pre> </div> <hr> <div> <h1>Is Mobile?</h1> <pre>{{ isMobile }}</pre> </div> <div> <h1>Is Tablet?</h1> <pre>{{ isTablet }}</pre> </div> <div> <h1>Is Desktop?</h1> <pre>{{ isDesktop }}</pre> </div> </div> |
FULL SOURCE CODE