【问题标题】:InjectionToken DocumentToken! - DOTNET CLI注入令牌文档令牌! - 点网命令行
【发布时间】:2018-02-07 01:48:36
【问题描述】:

我正在使用带有 Angular 模板的 Dotnet CLI 并运行应用程序,我必须执行 dotnet run 所以 --preserve-symlinks 不适用于 dotnet。

当我尝试执行 HttpClient 的方法 POST 时遇到同样的问题抛出 “InjectionToken DocumentToken 没有提供者!”。我尝试了一切,但我无法实现。

我尝试使用 "@angular/http" 中的 Http 并且它可以工作,但 HttpClient 不起作用。

有人可以帮助我吗?

我想使用 HttpClient 因为 HttpInterceptor。与导入和依赖注入相关的一切都可以。

类似帖子:NullInjectorError: No provider for InjectionToken DocumentToken

【问题讨论】:

  • 你需要使用来自@angular/common/http的HttpClient
  • 是的,我知道.. 但这不是错误。最后我修好了。
  • 对不起,我只是确保
  • 别担心,谢谢。

标签: .net angular httpclient


【解决方案1】:

最后我修好了。问题是依赖关系。 DOTNET 的实际版本安装了 Angular 4.2.5 的依赖项,我必须升级 4.4.6 并且它可以工作。

仅供参考,我的尝试也是使用最新版本的 angular,但依赖项不起作用,它们导致编译器出错。

"@angular/animations": "4.4.6",
"@angular/common": "4.4.6",
"@angular/compiler": "4.4.6",
"@angular/compiler-cli": "4.4.6",
"@angular/core": "4.4.6",
"@angular/forms": "4.4.6",
"@angular/http": "4.4.6",
"@angular/platform-browser": "4.4.6",
"@angular/platform-browser-dynamic": "4.4.6",
"@angular/platform-server": "4.4.6",
"@angular/router": "4.4.6",

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-14
    • 2022-10-15
    • 1970-01-01
    • 2013-08-12
    • 1970-01-01
    • 2019-07-07
    • 2019-05-31
    • 1970-01-01
    相关资源
    最近更新 更多