i have been following a tutorial on jwt authentication here
when i include MockConnection in the providers section of app.module.ts, i get this error:
SyntaxError {__zone_symbol__error: Error: Can't resolve all parameters for MockConnection: (?). at SyntaxError.ZoneAwareError (http……}
Here is my complete app.module.ts file:
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; import { DataTableModule } from '../../node_modules/primeng/components/datatable/datatable' ; import { CalendarModule } from '../../node_modules/primeng/components/calendar/calendar' ; // used to create fake backend import { fakeBackendProvider } from './helpers/fake.backend'; import { MockBackend, MockConnection } from '@angular/http/testing'; import { BaseRequestOptions } from '@angular/http'; import { AppComponent } from './app.component'; import { UpcomingManualDateComponent } from './components/opcon/upcoming-manual-date/upcoming-manual-date.component'; import { LogoComponent } from './components/logo/logo.component'; import { LoginComponent } from './components/login/login.component'; import { AppRoutingModule } from './app.routing' ; // import { IdentityGuard } from './guards/identity.guard'; import { IdentityService } from './services/identity/identity.service'; //import { UserService } from './services/user/user.service'; import { HomeComponent } from './components/home/home.component'; import { PagenotfoundComponent } from './components/pagenotfound/pagenotfound.component'; import { RegisterComponent } from './components/register/register.component' ; @NgModule({ declarations: [ AppComponent, UpcomingManualDateComponent, LogoComponent, LoginComponent, HomeComponent, PagenotfoundComponent, RegisterComponent ], imports: [ BrowserModule, DataTableModule , CalendarModule , FormsModule, HttpModule , AppRoutingModule ], providers: [ // IdentityGuard , IdentityService , // UserService , fakeBackendProvider , MockBackend , MockConnection , //<--CAUSES ERROR BaseRequestOptions ], bootstrap: [AppComponent] }) export class AppModule { }
Obviously, i am very new to Angular2. Can someone explain to me how this is causing an error?
When you see the app.module of the implementation, it does not contain MockConnection in the providers list
@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpModule,
routing
],
declarations: [
AppComponent,
LoginComponent,
HomeComponent
],
providers: [
AuthGuard,
AuthenticationService,
UserService,
// providers used to create fake backend
fakeBackendProvider,
MockBackend,
BaseRequestOptions
],
bootstrap: [AppComponent]
})
export class AppModule { }
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.