Skip to content

Commit

Permalink
build(7.0.0): release 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
AhsanAyaz committed Nov 20, 2023
1 parent 934c448 commit c546166
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 41 deletions.
14 changes: 12 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,23 @@ In your component where you want to use the Device Service

```

To ensure Universal has the correct User Agent for device detection, you'll need to provide it manually. If using ExpressJS for example:
For SSR, you have to make sure that the User Agent is available for device detection. I.e. you'll need to provide it manually. If using ExpressJS for example:

**express.tokens.ts**

```typescript
import { InjectionToken } from '@angular/core';
import { Request, Response } from 'express';

export const REQUEST = new InjectionToken<Request>('REQUEST');
export const RESPONSE = new InjectionToken<Response>('RESPONSE');
```

**universal-device-detector.service.ts:**

```typescript
import { Inject, Injectable, Optional, PLATFORM_ID } from '@angular/core';
import { REQUEST } from '@nguniversal/express-engine/tokens';
import { REQUEST } from 'path/to/express.tokens';
import { Request } from 'express';
import { DeviceDetectorService } from 'ngx-device-detector';
import { isPlatformServer } from '@angular/common';
Expand Down
11 changes: 8 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,15 @@ <h2 id="installation">Installation</h2>
}
...
}
</code></pre></div><p>To ensure Universal has the correct User Agent for device detection, you&#39;ll need to provide it manually. If using ExpressJS for example:</p>
<p><strong>universal-device-detector.service.ts:</strong></p>
</code></pre></div><p>For SSR, you have to make sure that the User Agent is available for device detection. I.e. you&#39;ll need to provide it manually. If using ExpressJS for example:</p>
<p><strong>express.tokens.ts</strong></p>
<div><pre class="line-numbers"><code class="language-typescript">import { InjectionToken } from &#39;&#64;angular/core&#39;;
import { Request, Response } from &#39;express&#39;;

export const REQUEST = new InjectionToken&lt;Request&gt;(&#39;REQUEST&#39;);
export const RESPONSE = new InjectionToken&lt;Response&gt;(&#39;RESPONSE&#39;);</code></pre></div><p><strong>universal-device-detector.service.ts:</strong></p>
<div><pre class="line-numbers"><code class="language-typescript">import { Inject, Injectable, Optional, PLATFORM_ID } from &#39;&#64;angular/core&#39;;
import { REQUEST } from &#39;&#64;nguniversal/express-engine/tokens&#39;;
import { REQUEST } from &#39;path/to/express.tokens&#39;;
import { Request } from &#39;express&#39;;
import { DeviceDetectorService } from &#39;ngx-device-detector&#39;;
import { isPlatformServer } from &#39;&#64;angular/common&#39;;
Expand Down
4 changes: 2 additions & 2 deletions docs/js/search/search_index.js

Large diffs are not rendered by default.

49 changes: 17 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions projects/ngx-device-detector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,23 @@ In your component where you want to use the Device Service

```

To ensure Universal has the correct User Agent for device detection, you'll need to provide it manually. If using ExpressJS for example:
For SSR, you have to make sure that the User Agent is available for device detection. I.e. you'll need to provide it manually. If using ExpressJS for example:

**express.tokens.ts**

```typescript
import { InjectionToken } from '@angular/core';
import { Request, Response } from 'express';

export const REQUEST = new InjectionToken<Request>('REQUEST');
export const RESPONSE = new InjectionToken<Response>('RESPONSE');
```

**universal-device-detector.service.ts:**

```typescript
import { Inject, Injectable, Optional, PLATFORM_ID } from '@angular/core';
import { REQUEST } from '@nguniversal/express-engine/tokens';
import { REQUEST } from 'path/to/express.tokens';
import { Request } from 'express';
import { DeviceDetectorService } from 'ngx-device-detector';
import { isPlatformServer } from '@angular/common';
Expand Down

0 comments on commit c546166

Please sign in to comment.