angular2 universal - ReferenceError: document is not defined

1,551 views
Skip to first unread message

David Montgomery

unread,
Oct 17, 2016, 4:36:54 AM10/17/16
to angular-material2
hi,

I m using angular2 universal an d using the webpack starter from angular class.


I have 2 issues.

1) I see the below in the below in the console where I start the app.....

but not in the chrome console


[nodemon] restarting due to changes...

[nodemon] starting `node dist/server/index.js`

Listening on: http://localhost:3000

EXCEPTION: document is not defined
ORIGINAL STACKTRACE:
ReferenceError: document is not defined
    at new RippleRenderer (/Users/test/Documents/frontend/duelabel-starter/node_modules/@angular/material/material.umd.js:193:31)
    at new MdRipple (/Users/test/Documents/frontend/duelabel-starter/node_modules/@angular/material/material.umd.js:327:32)
    at AppView._View_MdButton1.createInternal (MdButton.ngfactory.js:63:24)
    at AppView.create (/Users/test/Documents/frontend/duelabel-starter/node_modules/@angular/core/bundles/core.umd.js:9178:25)
    at TemplateRef_.createEmbeddedView (/Users/test/Documents/frontend/duelabel-starter/node_modules/@angular/core/bundles/core.umd.js:7263:18)
    at ViewContainerRef_.createEmbeddedView (/Users/test/Documents/frontend/duelabel-starter/node_modules/@angular/core/bundles/core.umd.js:5103:39)
    at NgIf.set [as ngIf] (/Users/test/Documents/frontend/duelabel-starter/node_modules/@angular/common/bundles/common.umd.js:1632:41)
    at AppView._View_MdButton0.detectChangesInternal (MdButton.ngfactory.js:42:25)
    at AppView.detectChanges (/Users/test/Documents/frontend/duelabel-starter/node_modules/@angular/core/bundles/core.umd.js:9325:18)
    at AppView.detectViewChildrenChanges (/Users/test/Documents/frontend/duelabel-starter/node_modules/@angular/core/bundles/core.umd.js:9351:23)
EXCEPTION: document is not defined
ORIGINAL STACKTRACE:

2) How do I load themes with webpack?

I had to copy themes to the asset folder to work


In regular angular2 with angular-cli which I love! it works as expected.






David Montgomery

unread,
Oct 19, 2016, 4:20:47 AM10/19/16
to angular-material2
Is there an issue with my question or am better off posting on stackoverflow......????

Michael Prentice

unread,
Nov 10, 2016, 6:31:33 PM11/10/16
to angular-material2
Material2 does not support Angular Universal at this time (https://github.com/angular/material2/issues/308) but plans are in place to make this work.

As for theming, that is covered in the docs here: https://github.com/angular/material2/blob/2.0.0-alpha.10/docs/theming.md

Michael Prentice
Reply all
Reply to author
Forward
0 new messages