我试图将ng2-pdf-viewer添加到我的angular2项目中,但是我在使用Angular-CLI进行设置时遇到了问题,指南说我应该将maping添加到systemjs但是有角度-cli现在不使用systemjs。 我尝试在angular-cli.json中添加lib的路径,但它给了我同样的错误。
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)
我从组件得到的错误,该组件使用pdfjs-dist并且它不包含任何ts文件,因为我不能使用systemjs作为指南说我需要一些帮助包括它。
角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
}
}
答案 0 :(得分:0)
检查How to integrate third party libraries
上的Angular-CLI文档您只需要在angular-cli.json
文件中的脚本对象中包含相应的JS文件。
希望这会有所帮助!!