I have installed ng2-pdf-viewer to show documents within angular 6 app.
To make it work I need to import PdfViewerModule in FeatureModule
where I want to use <ng2-pdf-viewer>
component.
The problem is in PdfViewerModule
, it calls Element and Window object inside its functions and it crushes when serving node server.js
.
At the moment my modules are imported like this:
BrowserModule > AppModule > FeatureModule > PdfViewerModule(declare <ng2-pdf-viewer>)
Usually I can solve such issues by importing such specific module directly into BrowserModule
and supply ServerModule
with some customly created mocked module which might declare samely named <ng2-pdf-viewer>
mock.
The solution I thought about is to import PdfViewerModule
in BrowserModule
directly, like this:
BrowserModule(imports PdfViewerModule) > AppModule > FeatureModule
but in this case components of FeatureModule
cant access <ng2-pdf-viewer>
in their templates because it is not declared.
Is there a way to isolate PdfViewerModule
from server-side execution, but keep its declarations?
Maybe there is absolutely diffrent approach fir such cases?
Thank you in advance! :)