0

I am using Angular components in Angular universal sample.

My Angular components are wrapper of java script widget and widget uses window.jqueryto render control.

when m importing my Angular components m facing issue like below.

An unhandled exception occurred while processing the request. Exception: Call to Node module failed with error: Prerendering failed because of error: ReferenceError: window is not defined at Object. (E:\Incident sample\130606\aspnetcore-angular2- universal-master\Client\dist\main-server.js:30544:9) at Object. (E:\Incident sample\130606\aspnetcore- angular2-universal-master\Client\dist\main-server.js:30545:3) at webpack_require (E:\Incident sample\130606\aspnetcore- angular2-universal-master\Client\dist\main-server.js:26:30) at Object. (E:\Incident sample\130606\aspnetcore- angular2-universal-master\Client\dist\main-server.js:19344:2)

Any one help me to find out issue.

But m seeing window is not supported in Angular universal . Anyway to use these angular components?

Thanks !!

Kbvin
  • 216
  • 3
  • 13

1 Answers1

-1

You can use HostListener Decorator instead of windows it will give you same feel like windows event

https://angular.io/docs/ts/latest/api/core/index/HostListener-interface.html

checkout above link and you will have better idea.

Also it is best practice to use HostListener instead of windows

This is for more details

https://codecraft.tv/courses/angular/custom-directives/hostlistener-and-hostbinding/

Hope this helps

Jalay Oza
  • 772
  • 7
  • 11