在app.component.ts中导入HTTP_PROVIDERS

Moh*_*nda 6 angular

当我尝试从angular/http导入HTTP_PROVIDERS时出现此错误:

Error:(3, 9) TS2305: Module '"projectname/node_modules/@angular/http/index"' has no exported member 'HTTP_PROVIDERS'.
Run Code Online (Sandbox Code Playgroud)

这是我的文件内容:

import { Component } from '@angular/core';
import {GithubService} from './services/github.service';
import {HTTP_PROVIDERS} from  '@angular/http';

@Component({
    selector: 'my-app',
    template: '<h1>My First Angular 2 App</h1><Profile></Profile>',
    providers: [ HTTP_PROVIDERS, GithubService ]
})

export class AppComponent { }
Run Code Online (Sandbox Code Playgroud)

Gün*_*uer 9

如果你使用的是> = RC.5添加HttpModuleimports@NgModule代替:

@NgModule({
  imports: [HttpModule],
  ...
})
class AppModule {}
Run Code Online (Sandbox Code Playgroud)