Skip to content
This repository was archived by the owner on Feb 16, 2021. It is now read-only.
This repository was archived by the owner on Feb 16, 2021. It is now read-only.

An error in angular4 #28

@baihech

Description

@baihech

我在google搜索到了一个angular2-interceptors的配置例子,我用这个例子配置了拦截器,但是工作起来有个异常,请问您准备支持angular4么?
I google search for an angular2-interceptors configuration example, I use this example configuration of the interceptor, but there is an exception to work, ask you ready to support the angular4?
Angular2 Http拦截器 Interceptor 实现

@angular/cli编译代码时会提示provideInterceptorService不存在,但是当你修改了某些代码后,watch到重新编译时,代码可以正确运行了。。

@Angular/cli Compile the code will prompt provideInterceptorService does not exist, but when you modify some of the code, watch to re-compile, the code can run correctly.

app.module.ts

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    HttpModule,
    CoreModule,
    LayoutModule,
    SharedModule.forRoot(),
    RoutesModule,
    TranslateModule.forRoot({
      loader: {
        provide: TranslateLoader,
        useFactory: HttpLoaderFactory,
        deps: [Http]
      }
    })
  ],
  providers: [HttpInterceptor,
    **provideInterceptorService**([
      HttpInterceptor
    ])
  ],
  bootstrap: [AppComponent]
})
export class AppModule {
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions