fix(angular): provideHttpClient when HttpClientModule is present in the imports array

This commit is contained in:
Mostafa Sherif 2023-02-09 05:22:54 -05:00
parent b015e7dca7
commit 1390642f10

View File

@ -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];
};