Angular 2 : No provider for ConnectionBackend

后端 未结 1 1328
慢半拍i
慢半拍i 2020-12-09 15:20

Get this \"No provider for ConnectionBackend!\" error when trying to use http with a promise.

main.ts

// ... tl;dr import a bunch of          


        
相关标签:
1条回答
  • 2020-12-09 16:04

    Import the HttpModule in your module instead of registering Http as a provider.

    import {HttpModule} from '@angular/http';
    
    @NgModule({
     imports: [HttpModule], 
     declarations: [
            PostComponent
      ],
      providers: [
        Actions,
        MyService
    
      ],
      bootstrap: [MyComponent]
    })
    

    The HttpModule registers providers for all its services.

    0 讨论(0)
提交回复
热议问题