node.js - 错误: Unexpected value 'HttpClient' imported by the module 'AppModule' . 请添加@NgModule注解

标签 node.js angular cordova uber-api

我不明白为什么会出现此错误:

Error: Unexpected value 'HttpClient' imported by the module 'AppModule'. Please add a @NgModule annotation.

我都试过了:

import { HttpClient } from '@angular/common/http';

import { HttpClientModule } from '@angular/common/http';

这是完整的错误:

Error: Unexpected value 'HttpClient' imported by the module 'AppModule'. Please add a @NgModule annotation.
at syntaxError (http://localhost:8100/build/vendor.js:116430:34)
at http://localhost:8100/build/vendor.js:131184:44
at Array.forEach (<anonymous>)
at CompileMetadataResolver.getNgModuleMetadata (http://localhost:8100/build/vendor.js:131159:49)
at JitCompiler._loadModules (http://localhost:8100/build/vendor.js:150357:87)
at JitCompiler._compileModuleAndComponents (http://localhost:8100/build/vendor.js:150318:36)
at JitCompiler.compileModuleAsync (http://localhost:8100/build/vendor.js:150212:37)
at CompilerImpl.compileModuleAsync (http://localhost:8100/build/vendor.js:115251:49)
at PlatformRef.bootstrapModule (http://localhost:8100/build/vendor.js:5952:25)
at Object.491 (http://localhost:8100/build/main.js:2405:109)

ionic 框架:3.9.2 Ionic Native:^2.9.0 Ionic 应用程序脚本:3.2.4 Angular 核心:5.2.11 Angular 编译器 CLI:5.2.11 Node :8.10.0 操作系统:Windows 10

最佳答案

您需要导入 HttpClientModule,例如:

 import { HttpClientModule } from '@angular/common/http';

 @NgModule({
   imports: [
     BrowserModule,
     // import HttpClientModule after BrowserModule.
     HttpClientModule,
  ],
  declarations: [
     AppComponent,
  ],
  bootstrap: [ AppComponent ]
})

export class AppModule {}

阅读:Angula HttpClient

关于node.js - 错误: Unexpected value 'HttpClient' imported by the module 'AppModule' . 请添加@NgModule注解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57064015/

相关文章:

node.js - Nodejs无法与express一起运行

具有 "russian dolls"组件的 Angular 循环依赖

Cordova ,内容安全策略 : within iframe getting error as deviceready has not fired after 5 seconds

javascript - Angular 2.0 ng-for 不显示 html 标签内的值

cordova - 什么时候应该使用 PhoneGap 构建?

iphone - 如何在 Phonegap 中实现 AdMob

node.js - NodeJS 中的非捕获分支重置正则表达式

node.js - mongodb使用更新来避免竞争条件,当字段为空数组时更新错误

node.js - TypeError : this. 模型不是函数

json - Angular 引导错误 npm ERR!代码生命周期