我到处寻找,却找不到我做错了什么。我使用angular 2向我的节点服务器api发送GET请求,并获取在我的组件中使用数据绑定显示的信息,称为trade。当我尝试查看我的角度应用程序时,在webbrowser上发生错误。我的nodejs app和angular2 app都在同一台服务器上运行。
答案 0 :(得分:1)
你有HttpModule导入你的一个Angular模块吗?
以下是我的一个例子:
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 { }