I have a customerService
where I am attempting to inject httpClient
. The error occurs on the line where I commented //error happens on this line
. Everything works fine until I try to inject httpClient into my service.
The error message is:
`compiler.js:485 Uncaught Error: Can't resolve all parameters for CustomerService: (?).
at syntaxError (compiler.js:485)
at CompileMetadataResolver._getDependenciesMetadata (compiler.js:15700)
at CompileMetadataResolver._getTypeMetadata (compiler.js:15535)
at CompileMetadataResolver._getInjectableMetadata (compiler.js:15515)
at CompileMetadataResolver.getProviderMetadata (compiler.js:15875)
at compiler.js:15786
at Array.forEach (<anonymous>)
at CompileMetadataResolver._getProvidersMetadata (compiler.js:15746)
at CompileMetadataResolver.getNgModuleMetadata (compiler.js:15314)
at CompileMetadataResolver.getNgModuleSummary
(compiler.js:15133)`
I'm not sure where to begin debugging this. Any help would be greatly appreciated. Thank you!
import { Observable } from "rxjs";
import { Injectable } from "@angular/core";
import { HttpClient } from "@angular/common/http";
@Injectable()
export class CustomerService {
private baseUri: string = "hosthere.com"
constructor(
private http: HttpClient //error happens on this line
) { }
get(email: string): Observable<any> {
const uri = `${this.baseUri}/customer/${email}`;
return this.http.get(uri).map(res => res.json());
}
}
Here is my Customer Module
import { NgModule } from "@angular/core";
import { SharedModule } from "../../shared/shared.module";
import { CustomerRouteModule } from "./cutomer.route.module";
import { SearchComponent } from "./";
import { CustomerService } from "../../services";
@NgModule({
imports: [SharedModule, CustomerRouteModule],
declarations: [SearchComponent],
providers: [CustomerService],
exports: []
})
export class CustomerModule {
}
Here is my shared module
import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { HttpClientModule } from "@angular/common/http";
import { AppMaterialModule } from "./app.material.module";
import { FlexLayoutModule } from "@angular/flex-layout";
import { HttpClientProvider } from "../services";
@NgModule({
imports: [
CommonModule,
FormsModule,
ReactiveFormsModule,
HttpClientModule ,
AppMaterialModule
],
providers: [
],
exports: [
AppMaterialModule,
FlexLayoutModule,
FormsModule,
HttpClientModule
]
})
export class SharedModule {
}