Skip to content

Commit

Permalink
Merge pull request #21028 from sheriffMoose/angular/provide-http-client
Browse files Browse the repository at this point in the history
fix(angular): provideHttpClient when HttpClientModule is present in the imports array
  • Loading branch information
sheriffMoose authored Feb 9, 2023
2 parents b015e7d + 1390642 commit 3d8a74f
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CommonModule } from '@angular/common';
import { Component, InjectionToken, NgModule, Provider } from '@angular/core';
import { HttpClientModule, provideHttpClient } from '@angular/common/http';
import { InjectionToken, NgModule, Provider } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {
BrowserAnimationsModule,
@@ -41,6 +42,13 @@ const analyzeRestricted = (ngModule: NgModule) => {
return [true, provideNoopAnimations()];
}

/**
* HttpClient has to be provided manually as a singleton
*/
if (ngModule === HttpClientModule) {
return [true, provideHttpClient()];
}

return [false];
};

0 comments on commit 3d8a74f

Please sign in to comment.