Angular 4 Error: No provider for HttpClient

后端 未结 5 1364
北恋
北恋 2020-12-25 09:40

I am starting a new angular project with the CLI and am running into a no provider for HttpClient error.

I have added HttpClientModule to m

5条回答
  •  借酒劲吻你
    2020-12-25 10:22

    An easier way is to provide it globally....Import the following into app.module.ts like so:

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

    and declare it in imports:

      imports: [
        HttpModule,
        HttpClientModule, ...
    ]
    

提交回复
热议问题