2017-08-31 85 views
0

enter image description here沒有提供對HTTP角+ Node.js的API

我看着到處找不到我在做什麼錯。我正在使用angular 2向我的節點服務器api發送一個GET請求,並在我的稱爲trade的組件中獲取它與數據綁定顯示的信息。當我嘗試查看我的角度應用程序時,該錯誤發生在webbrowser上。我的nodejs應用程序和angular2應用程序都在同一臺服務器上運行。

服務: https://hastebin.com/ileqekites.js

組件: https://hastebin.com/agopopadus.cs

+1

的[角2無提供商HTTP](可能的複製https://stackoverflow.com/questions/33721276/angular-2-no-provider - 用於-HTTP) – Kuncevic

回答

1

你有HTTP模塊導入到你的角模塊中的一個?

這裏是礦作爲示例之一:

import { NgModule } from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 
import { HttpModule } from '@angular/http';    // <- HERE 
import { RouterModule } from '@angular/router'; 

import { AppComponent } from './app.component'; 
import { WelcomeComponent } from './home/welcome.component'; 

/* Feature Modules */ 
import { ProductModule } from './products/product.module'; 

@NgModule({ 
    imports: [ 
    BrowserModule, 
    HttpModule,           // <- HERE 
    RouterModule.forRoot([ 
     { path: 'welcome', component: WelcomeComponent }, 
     { path: '', redirectTo: 'welcome', pathMatch: 'full' }, 
     { path: '**', redirectTo: 'welcome', pathMatch: 'full' } 
    ]), 
    ProductModule 
    ], 
    declarations: [ 
    AppComponent, 
    WelcomeComponent 
    ], 
    bootstrap: [ AppComponent ] 
}) 
export class AppModule { } 
相關問題