From 32ff988b2faab8cba95ce673f179a01fac9ae813 Mon Sep 17 00:00:00 2001 From: Olivier Combe Date: Wed, 6 Apr 2016 11:53:08 +0200 Subject: [PATCH] fix(common): only use window if available This makes ui-router usable server side for Angular Universal --- src/common/common.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/common/common.ts b/src/common/common.ts index 3f7d4d25f..44fe8f251 100644 --- a/src/common/common.ts +++ b/src/common/common.ts @@ -7,7 +7,8 @@ import {isFunction, isString, isArray, isRegExp, isDate} from "./predicates"; import { all, any, not, prop, curry } from "./hof"; -let angular = ( window).angular || {}; +let w: any = typeof window === 'undefined' ? {} : window; +let angular = w.angular || {}; export const fromJson = angular.fromJson || JSON.parse.bind(JSON); export const toJson = angular.toJson || JSON.stringify.bind(JSON); export const copy = angular.copy || _copy;