NativeScript No Http Provider

Follow the instructions of NativeScript Groceries Typescript Angular and I am 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 went back and forth through the textbook to see if I had missed something, but it seemed like I was diligently following every step.

How to solve this problem.

+4
source share
2 answers

Update

If you got this because of the NativeScript Angular2 Typescript tutorial, the next step fixes the problem (as of this writing).

Original

There seems to be no step in the textbook.

I had to add the following two lines:

// app.module.ts

import { NativeScriptHttpModule } from "nativescript-angular";

NativeScriptHttpModule

I ended up 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 { }
+12
source

, HTTP_PROVIDER :

 import { HTTP_PROVIDERS } from '@angular/http';

 nativeScriptBootstrap(AppComponent, [HTTP_PROVIDERS]);
0

Source: https://habr.com/ru/post/1652836/


All Articles