File

projects/demo/src/app/server.ts

Extends

DeviceDetectorService

Index

Properties
Methods

Constructor

constructor(platformId: any, request: Request)
Parameters :
Name Type Optional
platformId any No
request Request No

Methods

Public getDeviceInfo
getDeviceInfo()
Inherited from DeviceDetectorService
Returns : DeviceInfo

the device information object.

Public isDesktop
isDesktop(userAgent)
Inherited from DeviceDetectorService

if the current device is a desktop device.

Parameters :
Name Optional Default value
userAgent No this.userAgent
Returns : boolean

whether the current device is a desktop device

Public isMobile
isMobile(userAgent)
Inherited from DeviceDetectorService

if the current device is a mobile and also check current device is tablet so it will return false.

Parameters :
Name Optional Default value
userAgent No this.userAgent
Returns : boolean

whether the current device is a mobile

Public isTablet
isTablet(userAgent)
Inherited from DeviceDetectorService

if the current device is a tablet.

Parameters :
Name Optional Default value
userAgent No this.userAgent
Returns : boolean

whether the current device is a tablet

setDeviceInfo
setDeviceInfo(ua)
Inherited from DeviceDetectorService

This value is later accessible for usage

Parameters :
Name Optional Default value
ua No this.userAgent
Returns : void

Properties

browser
Type : string
Default value : ''
Inherited from DeviceDetectorService
browser_version
Type : string
Default value : ''
Inherited from DeviceDetectorService
device
Type : string
Default value : ''
Inherited from DeviceDetectorService
deviceType
Type : string
Default value : ''
Inherited from DeviceDetectorService
orientation
Type : string
Default value : ''
Inherited from DeviceDetectorService
os
Type : string
Default value : ''
Inherited from DeviceDetectorService
os_version
Type : string
Default value : ''
Inherited from DeviceDetectorService
reTree
Default value : new ReTree()
Inherited from DeviceDetectorService
ua
Type : string
Default value : ''
Inherited from DeviceDetectorService
userAgent
Type : string
Default value : ''
Inherited from DeviceDetectorService
import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';

import { AppModule } from './app.module';
import { AppComponent } from './app.component';
import { Inject, Injectable, Optional, PLATFORM_ID } from '@angular/core';
import { REQUEST } from '../express.tokens';
import { Request } from 'express';
import { DeviceDetectorService } from 'ngx-device-detector';
import { isPlatformServer } from '@angular/common';

@Injectable()
export class UniversalDeviceDetectorService extends DeviceDetectorService {
  constructor(@Inject(PLATFORM_ID) platformId: any, @Optional() @Inject(REQUEST) request: Request) {
    super(platformId);
    if (isPlatformServer(platformId)) {
      super.setDeviceInfo((request.headers['user-agent'] as string) || '');
    }
  }
}

@NgModule({
  imports: [AppModule, ServerModule],
  bootstrap: [AppComponent],
  providers: [
    {
      provide: DeviceDetectorService,
      useClass: UniversalDeviceDetectorService,
    },
  ],
})
export class AppServerModule {}

results matching ""

    No results matching ""