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

angular 4 server side prerending in CustomErrorHandler #85

Open
trackx2k17 opened this issue Jun 19, 2017 · 1 comment
Open

angular 4 server side prerending in CustomErrorHandler #85

trackx2k17 opened this issue Jun 19, 2017 · 1 comment

Comments

@trackx2k17
Copy link

Hi,

I got an error during server side prerending

Exception: Call to Node module failed with error: ReferenceError: window is not defined at ToastyComponent._setTimeout

`import {ErrorHandler, Inject, NgZone} from "@angular/core";
import {ToastyService} from "ng2-toasty";

export class AppErrorHandler implements ErrorHandler {

constructor(
    private ngZone: NgZone,
    @Inject(ToastyService) private toastyService: ToastyService){}

handleError(error: any): void {

    this.ngZone.run( () => {
        console.log(error);
        this.toastyService.error({
            title: 'Error',
            msg: 'An unexpected error happened.',
            theme: 'bootstrap',
            showClose: true,
            timeout: 5000
        });
    });
}

}`

if i use direcly toasty inside a compononent without the error handler class.... the prereding works well i can refresh the page without any problem.... only during the prerending using the error handler class

Any idea how to fix that

Thanks in advance

@dworky
Copy link

dworky commented Aug 26, 2017

@trackx2k17

        if (typeof(window) !== 'undefined') {
            this._toastyService.error({
                title: 'Error',
                msg: 'An unexpected error happened.',
                showClose: true,
                timeout: 5000,
                theme: 'bootstrap' 
            });
        }

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

2 participants