के लिए कोई प्रदाता नहीं है, मैं सीएलआई के साथ एक नया कोणीय प्रोजेक्ट शुरू कर रहा हूं और HttpClient
त्रुटि के लिए कोई प्रदाता नहीं चला रहा हूं।कोणीय 4 त्रुटि: HttpClient
मैंने अपने मॉड्यूल आयात में HttpClientModule
जोड़ा है जो इस परिदृश्य में सामान्य अपराधी प्रतीत होता है। इसके अलावा बहुत कुछ नहीं ढूंढ रहा है इसलिए मुझे यकीन नहीं है कि समस्या क्या हो सकती है।
मेरी app.module.ts
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
HttpClientModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
और मेरी सेवा
@Injectable()
export class FlexSearchService {
constructor(private http: HttpClient) {}
getSavedSearchResult(index: string, queryName: string, query: string): Observable<any> {
const url = `${environment.flexUrl}/${index}/search`;
const item = new SearchQuery({queryName: queryName, variables: {q: query}});
return this.http.post(url, item);
}
}
और एनजी संस्करण निम्न उत्पादन
@angular/cli: 1.4.2
node: 6.9.4
os: darwin x64
@angular/animations: 4.4.4
@angular/common: 4.4.4
@angular/compiler: 4.4.4
@angular/core: 4.4.4
@angular/forms: 4.4.4
@angular/http: 4.4.4
@angular/platform-browser: 4.4.4
@angular/platform-browser-dynamic: 4.4.4
@angular/router: 4.4.4
@angular/cli: 1.4.2
@angular/compiler-cli: 4.4.4
@angular/language-service: 4.4.4
typescript: 2.3.4
मेरी tsconfig देता
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
मेरा परीक्षण
import { TestBed, inject } from '@angular/core/testing';
import { HttpClientModule } from '@angular/common/http';
import { FlexSearchService } from './flex-search.service';
describe('FlexSearchService',() => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [FlexSearchService, HttpClientModule]
});
});
it('should be created', inject([FlexSearchService], (service: FlexSearchService) => {
expect(service).toBeTruthy();
}));
किसी भी मदद की बहुत सराहना!
क्या आप सही त्रुटि संदेश पोस्ट कर सकते हैं? – yurzui
और कृपया अपना tsconfig.json – yurzui
जोड़ें जहां आपने फ्लेक्सशर्च सेवा प्रदान की थी? – yurzui