ng-pdf-make icon indicating copy to clipboard operation
ng-pdf-make copied to clipboard

Cannot import Module

Open boom235 opened this issue 7 years ago • 9 comments

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>

boom235 avatar May 23 '17 13:05 boom235

Are you using angular-cli, webpack or systemjs?

BennyFranco avatar May 23 '17 13:05 BennyFranco

@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 ;-)

boom235 avatar May 23 '17 14:05 boom235

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 `

boom235 avatar May 23 '17 14:05 boom235

no solution yet?

brunork26 avatar Jul 06 '17 20:07 brunork26

@brunork26 Check out #5 to see how you can use the native pdfmake js library in an Angular 4/Angular CLI app.

nkyordy avatar Jul 13 '17 20:07 nkyordy

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 avatar Aug 06 '17 09:08 Alexpechonov

@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...?

neo-xy avatar Jan 29 '18 13:01 neo-xy

I've managed to get this working, here's how I've done it.

  1. as per Alexpechonov answer in your app.module.ts just include these: import { PdfmakeService } from 'ng-pdf-make'; then in providers section in the same file add PdfmakeService

  2. 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"

  3. in your component import import { PdfmakeService } from 'ng-pdf-make/pdfmake/pdfmake.service'; in constructor add private pdfmake: PdfmakeService

then you have access to all your functions under this.pdfmake like this.pdfmake.open etc

good luck!

lokers avatar Feb 14 '18 12:02 lokers

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

NithMario avatar Mar 09 '20 09:03 NithMario