Am following the NativeScript Groceries Typescript Angular tutorial and I got stuck in chapter 3 with the following errors.
EXCEPTION: Error in ./AppComponent class AppComponent_Host - inline template:0:0
ORIGINAL EXCEPTION: No provider for Http!
ORIGINAL STACKTRACE:
Error: DI Exception
at NoProviderError.BaseException [as constructor] (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/src/facade/exceptions.js:27:23)
at NoProviderError.AbstractProviderError [as constructor] (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/src/di/reflective_exceptions.js:43:16)
at new NoProviderError (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/src/di/reflective_exceptions.js:80:16)
at ReflectiveInjector_._throwOrNull (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/src/di/reflective_injector.js:786:19)
at ReflectiveInjector_._getByKeyDefault (/data/data/org.nativescript.groceries/files/app/tns_modules/@angular/core/src/di/reflective_injector.js:814:25)
at ReflectiveInjector_._getByKey (/data/data/org.nativescript.groce
I have gone back and forth the tutorial to see if I missed something but it seems I followed every steps diligently.
How do I resolve this issue.
If you got here because of the NativeScript Angular2 Typescript tutorial, the next step fixes the problem (at the time of this writing).
Apparently, a step is missing from the tutorial.
I had to add the following 2 lines:
// app.module.ts
import { NativeScriptHttpModule } from "nativescript-angular";
NativeScriptHttpModule
I ended with the following (app.module.ts):
import { NgModule } from "@angular/core";
import { NativeScriptFormsModule } from "nativescript-angular/forms";
import { NativeScriptModule } from "nativescript-angular/platform";
import { NativeScriptHttpModule } from "nativescript-angular";
import { AppComponent } from "./app.component";
@NgModule({
imports: [
NativeScriptModule,
NativeScriptFormsModule,
NativeScriptHttpModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
Good Morning usually this error is caused by not bootstrapping the HTTP_PROVIDER in your application like so:
import { HTTP_PROVIDERS } from '@angular/http';
nativeScriptBootstrap(AppComponent, [HTTP_PROVIDERS]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With