Angular项目中 出现 NullInjectorError: No provider for HttpClient 的解决办法20190904

1. 在 app.module.ts 中引入模块

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

2. 在 @NgModule.imports 中引入它

@NgModule({
    ......
    imports: [
        ......
        HttpClientModule,
        ......
    ],
    ......
})
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章