错误:“无法解析e:(?)的所有参数." [英] Error: "Can't resolve all parameters for e: (?)."

查看:95
本文介绍了错误:“无法解析e:(?)的所有参数."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在部署到具有 angular-cli 的github页面后,我遇到了此类错误:

错误:无法解析e:(?)的所有参数."

本地应用程序有效. 您建议采取什么步骤找到问题所在?

尝试使用angular-cli beta29 beta30 .

UPD::出于测试目的,我已从应用程序中删除了Router.不,我只有一个猜测,那就是DI.

UPD2(找到位置):

问题在于覆盖RequestOptions,所以:

export class RequestOptionsService extends RequestOptions {}

以及提供者定义:

{ provide: RequestOptions, useClass: RequestOptionsService },

这仍然是我的问题.

  • 请勿覆盖RequestOptions构造函数-错误.
  • 使用空参数覆盖RequestOptions构造函数-没有错误
  • 使用参数覆盖RequestOptions构造函数-错误

这是我覆盖构造函数的方式:

constructor(options?: RequestOptionsArgs) {
  super(options);
}

这可能是什么问题?

UPD3(已解决情况):

问题确实出在RequestOptions上,所以您不应该这样做:

export class RequestOptionsService extends RequestOptions {}

但仅:

export class RequestOptionsService extends BaseRequestOptions {}

解决方案

请确保:

  • 您的tsconfig.js中有"emitDecoratorMetadata": true
  • 每项服务都不缺少@Injectable()装饰器
  • components构造函数注入您的服务(将它们作为 参数)

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 your tsconfig.js
  • every service is not missing @Injectable() decorator
  • components constructor injects your services (have them passed as parameters)

这篇关于错误:“无法解析e:(?)的所有参数."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆