NativeScript/nativescript-sdk-examples-ng

ERROR Error: No provider for HttpClient when used

somayaji1983 opened this issue · 2 comments

Dear team,
I have copied the code as it is and when invoke I am getting following error
ERROR Error: No provider for HttpClient

Hi, I am getting the same problem. Here is my app.module.ts and app.component.ts
app.module.ts
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { SpeechRecognition } from "nativescript-speech-recognition";
import { AppComponent } from "./app.component";
import { EventData, PropertyChangeData } from 'data/observable';
import { Page } from 'ui/page';
import { NativeScriptHttpClientModule } from "nativescript-angular/http-client";

@NgModule({
declarations: [AppComponent],
bootstrap: [AppComponent],
imports: [NativeScriptModule,NativeScriptHttpClientModule],
providers: [SpeechRecognition],
schemas: [NO_ERRORS_SCHEMA],
})
export class AppModule {}

app.component.ts

import { Component } from "@angular/core";
import { SpeechRecognition, SpeechRecognitionTranscription, SpeechRecognitionOptions } from "nativescript-speech-recognition";
import { EventData, PropertyChangeData } from 'data/observable';
import { Page } from "ui/page";
import { TextView } from "ui/text-view";
import { Switch } from "ui/Switch";
import { MyHttpGetService } from "./httpmodule/httpservice";

@component({
selector: "my-app",
templateUrl: './appview.html',
providers: [MyHttpGetService]
})

export class AppComponent {

options: SpeechRecognitionOptions;
public textvalue: string = "Say some thing..."
public led_visibility : string = "hidden";
public ledhttplink : string = "http://192.168.1.101:8080/"

public LedSwitchState : string;
public sendColor : string;

constructor(private speech: SpeechRecognition, private page: Page,private myService: MyHttpGetService){

I have pasted till constructor as I am getting error when the objected added to it. if I remove it is working find.

This is the error
JS: ERROR Error: No provider for MyHttpGetService!
JS: ERROR CONTEXT [object Object]
JS: ns-renderer: ERROR BOOTSTRAPPING ANGULAR
JS: ns-renderer: No provider for MyHttpGetService!

Please help

Hi @somayaji1983,
Make sure that you have made your service component injectable as it shown here in nativescript-sdk-examples-ng.

Also, it would help if you send us sample project, which could be used for debugging and more info about your environment(CLI modules, runtime, nativescript-angular versions)

lock commented

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.