错误:“无法解析 e: (?) 的所有参数." [英] Error: "Can't resolve all parameters for e: (?)."
问题描述
在使用 angular-cli 部署到 github-pages 后,我遇到了这种错误:
<块引用>错误:无法解析 e: (?) 的所有参数."
本地应用程序有效.您建议采取哪些步骤来找到问题所在?
尝试使用 angular-cli beta29 和 beta30.
UPD:出于测试目的,我已从应用程序中删除了路由器.不是,我只有一个猜测,它与 DI 有关系.
UPD2(找到地方):
问题在于覆盖RequestOptions
,所以这样做:
导出类 RequestOptionsService 扩展 RequestOptions {}
对于提供者定义:
{ 提供:RequestOptions, useClass: RequestOptionsService },
<块引用>
这对我来说仍然是一个问题.
- 不要覆盖
RequestOptions
构造函数 - 错误. - 用空参数覆盖
RequestOptions
构造函数 - 没有错误 - 用参数覆盖
RequestOptions
构造函数 - 错误
这是我如何覆盖构造函数的方式:
constructor(options?: RequestOptionsArgs) {超级(选项);}
这里有什么问题?
UPD3(解决了自己的案例):
问题确实出在 RequestOptions
上,所以你不应该这样做:
导出类 RequestOptionsService 扩展 RequestOptions {}
但仅限:
导出类 RequestOptionsService 扩展 BaseRequestOptions {}
请确保:
- 你的
tsconfig.js
中有 - 每个服务都不缺少
@Injectable()
装饰器 - components 构造函数注入您的服务(将它们作为参数)
"emitDecoratorMetadata": true
I have such kind of error after deployment to github-pages with angular-cli:
Error: "Can't resolve all parameters for e: (?)."
Local application works. What steps would you recommend to do to find the problem place?
Tried with angular-cli beta29 and beta30.
UPD: I've removed Router from the application for testing purposes. Not I have only one guess that it's something with DI.
UPD2(FOUND THE PLACE):
The problem is with overwriting RequestOptions
, so do:
export class RequestOptionsService extends RequestOptions {}
and for provider definition:
{ provide: RequestOptions, useClass: RequestOptionsService },
It's still a question for me.
- do not overwrite
RequestOptions
constructor - error. - overwrite
RequestOptions
constructor with empty parameter - no error - overwrite
RequestOptions
constructor with parameters - error
This is the way how I overwrite the constructor:
constructor(options?: RequestOptionsArgs) {
super(options);
}
What could be wrong here?
UPD3(Solved own case):
The problem indeed was with RequestOptions
, so you should not do:
export class RequestOptionsService extends RequestOptions {}
but only:
export class RequestOptionsService extends BaseRequestOptions {}
Make sure:
- you have
"emitDecoratorMetadata": true
in yourtsconfig.js
- every service is not missing
@Injectable()
decorator - components constructor injects your services (have them passed as parameters)
这篇关于错误:“无法解析 e: (?) 的所有参数."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!