Skip to content

global is not defined issue Angular 6 #46

Closed
@nickdekesel

Description

@nickdekesel

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)

Activity

vp93

vp93 commented on Jun 2, 2018

@vp93

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

mashhoodr commented on Jun 4, 2018

@mashhoodr
Collaborator

dup of (#44)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @mashhoodr@nickdekesel@vp93

        Issue actions

          global is not defined issue Angular 6 · Issue #46 · ksachdeva/angular2-swing