我想导入 HttpHeaders
但是当我导入它时出现这个错误:
Uncaught Error: Unexpected value 'HttpHeaders' imported by the module 'AppModule'. Please add a @NgModule annotation.
我导入这个:
import { HttpClientModule, HttpHeaders } from '@angular/common/http';
进入我的 app.module.ts
和 我的 service.ts
然后我导入这个:
@NgModule({
declarations: [
AppComponent,
PremierComComponent
],
imports: [
BrowserModule,
AppRoutingModule,
FormsModule,
HttpClientModule,
HttpHeaders,
],
providers: [],
bootstrap: [AppComponent]
})
在 app.module.ts
有人能解释一下如何解决这个错误吗?
最佳答案
HttpHeaders
是一个类。唯一应该在你的导入中的是一个模块数组,它们总是用 @NgModule
标签装饰。因此,您应该从导入数组中删除 HttpHeaders
。
来源:
关于javascript - angular 6 请添加@NgModule 注解,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53135600/