Skip to content

Instantly share code, notes, and snippets.

@bbogdanov
Created November 1, 2017 08:19
Show Gist options
  • Save bbogdanov/5ba35a620190274c4ed2c2645d86a39d to your computer and use it in GitHub Desktop.
Save bbogdanov/5ba35a620190274c4ed2c2645d86a39d to your computer and use it in GitHub Desktop.
Extending Angular HttpClient app.module
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { ApplicationHttpClient, applicationHttpClientCreator } from './http-client';
import { AppComponent } from './app.component';
import { HttpClient } from '@angular/common/http';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
HttpClientModule,
],
providers: [
// Providing the ApplicationHttpClient so it could be used as a service.
{
provide: ApplicationHttpClient,
useFactory: applicationHttpClientCreator,
deps: [HttpClient]
},
],
bootstrap: [AppComponent]
})
export class AppModule { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment