projects/demo/src/app/server.ts
Properties |
Methods |
|
constructor(platformId: any, request: Request)
|
|||||||||
|
Defined in projects/demo/src/app/server.ts:13
|
|||||||||
|
Parameters :
|
| Public getDeviceInfo |
getDeviceInfo()
|
|
Inherited from
DeviceDetectorService
|
|
Defined in
DeviceDetectorService:135
|
|
Returns :
DeviceInfo
the device information object. |
| Public isDesktop | ||||||
isDesktop(userAgent)
|
||||||
|
Inherited from
DeviceDetectorService
|
||||||
|
Defined in
DeviceDetectorService:191
|
||||||
|
if the current device is a desktop device.
Parameters :
Returns :
boolean
whether the current device is a desktop device |
| Public isMobile | ||||||
isMobile(userAgent)
|
||||||
|
Inherited from
DeviceDetectorService
|
||||||
|
Defined in
DeviceDetectorService:155
|
||||||
|
if the current device is a mobile and also check current device is tablet so it will return false.
Parameters :
Returns :
boolean
whether the current device is a mobile |
| Public isTablet | ||||||
isTablet(userAgent)
|
||||||
|
Inherited from
DeviceDetectorService
|
||||||
|
Defined in
DeviceDetectorService:171
|
||||||
|
if the current device is a tablet.
Parameters :
Returns :
boolean
whether the current device is a tablet |
| setDeviceInfo | ||||||
setDeviceInfo(ua)
|
||||||
|
Inherited from
DeviceDetectorService
|
||||||
|
Defined in
DeviceDetectorService:59
|
||||||
|
This value is later accessible for usage
Parameters :
Returns :
void
|
| browser |
Type : string
|
Default value : ''
|
|
Inherited from
DeviceDetectorService
|
|
Defined in
DeviceDetectorService:40
|
| browser_version |
Type : string
|
Default value : ''
|
|
Inherited from
DeviceDetectorService
|
|
Defined in
DeviceDetectorService:43
|
| device |
Type : string
|
Default value : ''
|
|
Inherited from
DeviceDetectorService
|
|
Defined in
DeviceDetectorService:41
|
| deviceType |
Type : string
|
Default value : ''
|
|
Inherited from
DeviceDetectorService
|
|
Defined in
DeviceDetectorService:45
|
| orientation |
Type : string
|
Default value : ''
|
|
Inherited from
DeviceDetectorService
|
|
Defined in
DeviceDetectorService:46
|
| os |
Type : string
|
Default value : ''
|
|
Inherited from
DeviceDetectorService
|
|
Defined in
DeviceDetectorService:39
|
| os_version |
Type : string
|
Default value : ''
|
|
Inherited from
DeviceDetectorService
|
|
Defined in
DeviceDetectorService:42
|
| reTree |
Default value : new ReTree()
|
|
Inherited from
DeviceDetectorService
|
|
Defined in
DeviceDetectorService:44
|
| ua |
Type : string
|
Default value : ''
|
|
Inherited from
DeviceDetectorService
|
|
Defined in
DeviceDetectorService:37
|
| userAgent |
Type : string
|
Default value : ''
|
|
Inherited from
DeviceDetectorService
|
|
Defined in
DeviceDetectorService:38
|
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 {}