简体   繁体   中英

No provider for ConnectionBackend

So recently I had to update to the latest version of Angular2, RC.6. The biggest breaking change seems to be the whole bootstrapping (by "introducing" ngModule).

@NgModule({
    imports: [HttpModule, BrowserModule, FormsModule],
    schemas: [CUSTOM_ELEMENTS_SCHEMA],
    declarations: [AppComponent, ...],
    providers: [FrameService, Http, { provide: $WINDOW,  useValue: window }],
    bootstrap: [AppComponent]
})
class AppModule {

}

platformBrowserDynamic().bootstrapModule(AppModule);

However after a lot of tears, sweat and pleading to all the deities I could come up with... I still remain with what is hopefully the last error in a series of many:

No provider for ConnectionBackend!

At this point I am tearing out the last strains of hair I have left as I am clueless at this point regarding the "what I am missing".

Kind regards!

Http is redundant in

providers: [FrameService, Http, { provide: $WINDOW,  useValue: window }],

because HttpModule in

imports: [HttpModule, BrowserModule, FormsModule],

provides it already.

In app.module.ts add:

import { HttpModule } from '@angular/http';

And import module:

imports: [
    ...
    HttpModule
    ...
  ],

I removed 'Http' from this import like this and it worked for me. Also, BrowserModule must come before HttpModule in the modume imports.

Before:

import { HttpModule, Http } from '@angular/http';

After:

import { HttpModule } from '@angular/http';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM