(SystemJS) Can't resolve all parameters for

前端之家收集整理的这篇文章主要介绍了(SystemJS) Can't resolve all parameters for前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

angular4中添加service的DI注入后,编译后在tomcat下运行,一直提示

(SystemJS) Can't resolve all parameters for TestComponent: (?).
	SyntaxError@http://localhost:8080/web/node_modules/@angular/compiler/bundles/compiler.umd.js:1513:34 [<root>]
	CompileMetadataResolver.prototype._getDependenciesMetadata@http://localhost:8080/web/node_modules/@angular/compiler/bundles/compiler.umd.js:14790:35 [<root>]
	CompileMetadataResolver.prototype._getTypeMetadata@http://localhost:8080/web/node_modules/@angular/compiler/bundles/compiler.umd.js:14658:21 [<root>]
	CompileMetadataResolver.prototype.getNonNormalizedDirectiveMetadata@http://localhost:8080/web/node_modules/@angular/compiler/bundles/compiler.umd.js:14267:19 [<root>]
	CompileMetadataResolver.prototype._getEntryComponentMetadata@http://localhost:8080/web/node_modules/@angular/compiler/bundles/compiler.umd.js:14911:40 [<root>]
	CompileMetadataResolver.prototype.getNgModuleMetadata/<@http://localhost:8080/web/node_modules/@angular/compiler/bundles/compiler.umd.js:14494:102 [<root>]
	CompileMetadataResolver.prototype.getNgModuleMetadata@http://localhost:8080/web/node_modules/@angular/compiler/bundles/compiler.umd.js:14494:53 [<root>]
	JitCompiler.prototype._loadModules@http://localhost:8080/web/node_modules/@angular/compiler/bundles/compiler.umd.js:25571:41 [<root>]
	JitCompiler.prototype._compileModuleAndComponents@http://localhost:8080/web/node_modules/@angular/compiler/bundles/compiler.umd.js:25530:47 [<root>]
	JitCompiler.prototype.compileModuleAsync@http://localhost:8080/web/node_modules/@angular/compiler/bundles/compiler.umd.js:25492:16 [<root>]
	PlatformRef_.prototype._bootstrapModuleWithZone@http://localhost:8080/web/node_modules/@angular/core/bundles/core.umd.js:4793:16 [<root>]
	PlatformRef_.prototype.bootstrapModule@http://localhost:8080/web/node_modules/@angular/core/bundles/core.umd.js:4779:16 [<root>]
	@http://localhost:8080/web/main.js:4:1 [<root>]
	@http://localhost:8080/web/main.js:1:31 [<root>]
	@http://localhost:8080/web/main.js:1:2 [<root>]
	scheduleResolveOrReject/<@http://localhost:8080/web/node_modules/zone.js/dist/zone.js:758:52 [<root>]
	drainMicroTaskQueue@http://localhost:8080/web/node_modules/zone.js/dist/zone.js:591:25 [<root>]
	ZoneTask/this.invoke@http://localhost:8080/web/node_modules/zone.js/dist/zone.js:464:25 [<root>]
	
	Evaluating http://localhost:8080/web/main.js
	Error loading http://localhost:8080/web/main.js  index

但在源码环境下运行正常,于是奇怪了。后来想到编译打包使用的grunt-ts,而编译是angular4提供的样例工程自动编译的,这2者会不会有差异。用对比工具对比后发现,还真有差异。

//danielinbiti

首先少了

var __Metadata = (this && this.__Metadata) || function (k,v) {
    if (typeof Reflect === "object" && typeof Reflect.Metadata === "function") return Reflect.Metadata(k,v);
};
又少了
__Metadata("design:paramtypes",[TestService_1.TestService])
于是就出现了参数无法识别的错误

看来编译方式还得再调整

在grunt-ts可以增加编译项:

emitDecoratorMetadata:true danielinbiti
原文链接:https://www.f2er.com/angularjs/147327.html

猜你在找的Angularjs相关文章