0
votes

i'm trying to add ng2-pdf-viewer to my angular2 project, but i'm having problems setting it up with Angular-CLI, the guide says that i should add the maping to systemjs but angular-cli doesn't use systemjs now. i tried adding the path to the lib in angular-cli.json but it gives me the same error.

Uncaught Error: Unexpected value 'PdfViewerComponent' declared by the module 'AppModule'
at http://localhost:3000/vendor.bundle.js:12183:31
at Array.forEach (native)
at CompileMetadataResolver.getNgModuleMetadata (http://localhost:3000/vendor.bundle.js:12170:49)
at RuntimeCompiler.compileComponents (http://localhost:3000/vendor.bundle.js:18476:47)
at RuntimeCompiler._compileModuleAndComponents (http://localhost:3000/vendor.bundle.js:18414:37)
at RuntimeCompiler.compileModuleAsync (http://localhost:3000/vendor.bundle.js:18405:21)
at PlatformRef.bootstrapModuleWithZone (http://localhost:3000/vendor.bundle.js:26818:25)
at PlatformRef.bootstrapModule (http://localhost:3000/vendor.bundle.js:26800:21)
at HTMLDocument.main (http://localhost:3000/main.bundle.js:89232:10)
at ZoneDelegate.invokeTask (http://localhost:3000/polyfills.bundle.js:15379:38)
at Zone.runTask (http://localhost:3000/polyfills.bundle.js:15279:48)
at HTMLDocument.ZoneTask.invoke (http://localhost:3000/polyfills.bundle.js:15447:34)

that's the error i get from the component, the component uses pdfjs-dist and it doesn't include any ts file and since i can't use systemjs as the guide says i need some help including it.

angular-cli.json:

 {
  "project": {
    "version": "1.0.0-beta.17",
    "name": "ng_pdf_app"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": "assets",
      "index": "index.html",
      "main": "main.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "app",
      "mobile": false,
      "styles": [
        "styles.css",
        "../node_modules/bootstrap/dist/css/bootstrap.min.css"
      ],
      "scripts": [
        "../node_modules/jquery/dist/jquery.js",
        "../node_modules/tether/dist/js/tether.js",
        "../node_modules/bootstrap/dist/js/bootstrap.js"
      ],
      "environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "addons": [],
  "packages": [ {"ng2-pdf-viewer":{ "main": "dist/pdf-viewer.component.min.js", "defaultExtension": "js" }},
    {"pdfjs-dist": { "defaultExtension": "js" }}],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "prefixInterfaces": false
  }
}

ng2-pdf-viewer

1

1 Answers

0
votes

Check Angular-CLI Documentation on How to integrate third party libraries

You just need to include respective JS files in scripts object in angular-cli.json file.

Hope this helps!!