Skip to content

Commit

Permalink
Merge pull request #474 from xthilakx/xthilakx/angular-universal-support
Browse files Browse the repository at this point in the history
Angular Universal Compatibility for Server Side Rendering
  • Loading branch information
neroniaky authored Sep 25, 2018
2 parents 2e48bce + 16798b3 commit 0fd5774
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions projects/angular-token/src/lib/angular-token.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Injectable, Optional, Inject } from '@angular/core';
import { Injectable, Optional, Inject, PLATFORM_ID } from '@angular/core';
import { ActivatedRoute, Router, CanActivate } from '@angular/router';
import { HttpClient } from '@angular/common/http';
import { isPlatformServer } from '@angular/common';

import { Observable, fromEvent, interval } from 'rxjs';
import { pluck, filter, tap, share, finalize } from 'rxjs/operators';
import { pluck, filter, share, finalize } from 'rxjs/operators';

import { ANGULAR_TOKEN_OPTIONS } from './angular-token.token';

Expand Down Expand Up @@ -53,9 +54,20 @@ export class AngularTokenService implements CanActivate {
constructor(
private http: HttpClient,
@Inject(ANGULAR_TOKEN_OPTIONS) config: any,
@Inject(PLATFORM_ID) private platformId: Object,
@Optional() private activatedRoute: ActivatedRoute,
@Optional() private router: Router
) {
if (isPlatformServer(platformId)) {
window = {
open: () => null,
location: {
href: '/',
origin: '/'
}
} as Window;
}

const defaultOptions: AngularTokenOptions = {
apiPath: null,
apiBase: null,
Expand Down

0 comments on commit 0fd5774

Please sign in to comment.