ng-pdf-make
ng-pdf-make copied to clipboard
Cannot import Module
When I try to import the module PdfmakeModule in my app.modules (as described in the README). I get the following error:
VM142214:15291 Uncaught Error: Unexpected value 'PdfmakeModule' imported by the module 'AppModule'. Please add a @NgModule annotation. at syntaxError (eval at <anonymous>
Are you using angular-cli, webpack or systemjs?
@BennyFranco I am using webpack2, this is based on angular-cli as far as I know. I am not using systemJS
I guess the other issues could describe the same problem. So if you would find a solution for this, maybe all the issues are resolved ;-)
Maybe it helps that I get these warnings before the error occurs:
`WARNING in ./~/ng-pdf-make/~/@angular/core/src/linker/system_js_ng_module_factory_loader.js 71:15-36 Critical dependency: the request of a dependency is an expression
WARNING in ./~/ng-pdf-make/~/@angular/core/src/linker/system_js_ng_module_factory_loader.js 87:15-102 Critical dependency: the request of a dependency is an expression `
no solution yet?
@brunork26 Check out #5 to see how you can use the native pdfmake js library in an Angular 4/Angular CLI app.
I found solution. Don't include full module, just add only service PdfmakeService to providers and add import {PdfmakeService} from 'ng-pdf-make/pdfmake/pdfmake.service'; to component.
@Alexpechonov it works the way U do it (y) but getting warnings: "'Critical dependency: the request of a dependency is an expression" any idea of how to get rid of thoes...?
I've managed to get this working, here's how I've done it.
-
as per Alexpechonov answer in your
app.module.ts
just include these:import { PdfmakeService } from 'ng-pdf-make';
then inproviders
section in the same file addPdfmakeService
-
in your
.angular-cli.json
add these two lines inside the"scripts"
array:"../node_modules/pdfmake/build/pdfmake.js", "../node_modules/pdfmake/build/vfs_fonts.js"
-
in your component import
import { PdfmakeService } from 'ng-pdf-make/pdfmake/pdfmake.service';
inconstructor
addprivate pdfmake: PdfmakeService
then you have access to all your functions under this.pdfmake
like this.pdfmake.open
etc
good luck!
it work but has warning WARNING in ./node_modules/ng-pdf-make/node_modules/@angular/core/src/util/lang.js 25:25-41 "export '$$observable' (imported as 'symbolObservable') was not found in 'rxjs/symbol/observable'
WARNING in ./node_modules/ng-pdf-make/node_modules/@angular/core/src/linker/system_js_ng_module_factory_loader.js 71:15-36 Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/ng-pdf-make/node_modules/@angular/core/src/linker/system_js_ng_module_factory_loader.js 87:15-102 Critical dependency: the request of a dependency is an expression