How to use the @angular/common.isPlatformServer function in @angular/common

To help you get started, we’ve selected a few @angular/common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alvarotrigo / angular-fullpage / src / angular-fullpage / lib / fullpage.directive.ts View on Github external
ngAfterViewInit() {
    if (isPlatformBrowser(this.platformId)) {
      this.initFullpage();
    }
    if (isPlatformServer(this.platformId)) {
      // server side code
    }
  }
github angular / flex-layout-builds / esm2015 / flex-layout.js View on Github external
constructor(serverModuleLoaded, platformId) {
        if (isPlatformServer(platformId) && !serverModuleLoaded) {
            console.warn('Warning: Flex Layout loaded on the server without FlexLayoutServerModule');
        }
    }
    /**
github abhijit-kar / dont-let-him-poo / src / app / shared / services / google-analytics.service.ts View on Github external
initGoogleAnalytics() {
    if (isPlatformServer(this.platformId)) {
      return;
    }

    try {
      window["ga"] =
        window["ga"] ||
        function() {
          (ga.q = ga.q || []).push(arguments);
        };
      ga.l = +new Date();
      ga("create", this.googleAnalyticsKey, "auto");
    } catch (e) {
      console.log(e);
    }
  }
github rucken / core / libs / rucken / core / src / lib / modules / auth / services / token.service.ts View on Github external
startCheckTokenHasExpired() {
    if (!isPlatformServer(this._platformId)) {
      this._checkTokenHasExpiredIntervalRef = setInterval(_ => {
        if (this.checkTokenHasExpired()) {
          this.tokenHasExpired = true;
        }
      }, 30 * 1000);
    }
  }
  getTokenData(token: string): { payload: { exp: number } } {
github thinktecture / windows-developer-cross-platform-article-series / universal / src / app / services / platform.ts View on Github external
public isServerApplication(): boolean {
    return isPlatformServer(this._platformId);
  }
}
github intershop / intershop-pwa / src / app / core / utils / http-status-code / http-status-code.service.ts View on Github external
setStatus(status: number) {
    if (isPlatformServer(this.platformId)) {
      this.response.status(status);
    }
  }
github johandb / svg-drawing-tool / node_modules / @angular / platform-browser / esm5 / src / dom / events / dom_events.js View on Github external
function DomEventsPlugin(doc, ngZone, platformId) {
        var _this = _super.call(this, doc) || this;
        _this.ngZone = ngZone;
        if (!platformId || !isPlatformServer(platformId)) {
            _this.patchEvent();
        }
        return _this;
    }
    DomEventsPlugin.prototype.patchEvent = function () {
github SAP / cloud-commerce-spartacus-storefront / projects / core / src / occ / config-loader / occ-config-loader.service.ts View on Github external
protected transfer(externalConfig: OccLoadedConfig) {
    if (
      this.transferState &&
      isPlatformServer(this.platform) &&
      externalConfig
    ) {
      this.transferState.set(EXTERNAL_CONFIG_TRANSFER_ID, externalConfig);
    }
  }
github OmicsDI / ddi-web-app / src / app / shared / services / profile.service.ts View on Github external
setProfile(profile: Profile): void {
        if (isPlatformServer(this.platformId)) {
            return;
        }
        if (profile.dataSets == null) {
            profile.dataSets = [];
        }
        localStorage.removeItem('profile');
        localStorage.setItem('profile', JSON.stringify(profile));
    };
github OmicsDI / ddi-web-app / src / app / modules / home / components / repos-omics / repos-omics.component.ts View on Github external
constructor(dataSetService: DataSetService,
                private router: Router,
                private http: HttpClient,
                @Inject(PLATFORM_ID) private platformId: string) {
        super();
        this.isServer = isPlatformServer(this.platformId);
        this.webServiceUrl = dataSetService.getWebServiceUrl();
        this.proteomicsList = dataSetService.getProteomicsList();
        this.metabolomicsList = dataSetService.getMetabolomicsList();
        this.genomicsList = dataSetService.getGenomicsList();
        this.transcriptomicsList = dataSetService.getTranscriptomicsList();
    }