Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

global is not defined issue Angular 6 #46

Closed
nickdekesel opened this issue Jun 2, 2018 · 2 comments
Closed

global is not defined issue Angular 6 #46

nickdekesel opened this issue Jun 2, 2018 · 2 comments

Comments

@nickdekesel
Copy link

Card.js is throwing errors in Angular 6 which makes it unusable.

ERROR ReferenceError: global is not defined at Card.js:205 at construct (Card.js:210) at Card (Card.js:364) at Object.Stack.stack.createCard (Stack.js:81) at SwingStackComponent.push../node_modules/angular2-swing/dist/swing-stack-component.js.SwingStackComponent.addCard (swing-stack-component.js:24) at SwingCardComponent.push../node_modules/angular2-swing/dist/swing-card-component.js.SwingCardComponent.ngOnInit (swing-card-component.js:12) at checkAndUpdateDirectiveInline (core.js:10097) at checkAndUpdateNodeInline (core.js:11363) at checkAndUpdateNode (core.js:11325) at debugCheckAndUpdateNode (core.js:11962)

@vp93
Copy link

vp93 commented Jun 2, 2018

There are 2 ways to fix this :
#1. You can either add these following lines in the < head > element of your index.html:

<script>
      if (global === undefined) {
        var global = window;
     }
</script> 

#2. A cleaner fix would be to add this line as the first line in the polyfills.ts file :

(window as any).global = window;

This issue started with the release of angular5 as the app tries to refer to the window element ( in this case , from Card.js ) before angular attaches the 'global' variable to it.

@mashhoodr
Copy link
Collaborator

dup of (#44)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants