angular2导入HTTP_PROVIDERS
错误消息>>
@ angular / http / index“’没有导出的成员’HTTP_PROVIDERS’.
import { Component } from '@angular/core'; import {NoticeService} from './products/product.service'; import {HTTP_PROVIDERS} from '@angular/http'; import 'rxjs/Rx'; @Component({ selector: 'my-app',template: ` <h1>Hello {{name}}</h1> <pm-products></pm-products> `,providers: [NoticeService,HTTP_PROVIDERS] })
解决方法
您不再需要HTTP_PROVIDERS(不建议使用).改为导入http模块.
import { NgModule } from '@angular/core'; import { HttpModule } from '@angular/http'; import { BrowserModule } from '@angular/platform-browser'; import { AppComponent } from './app.component'; @NgModule({ imports: [ BrowserModule,HttpModule ],declarations: [AppComponent],providers: [],bootstrap: [AppComponent],}) export class AppModule { }