Angular2 import HTTP_PROVIDERS error

angular2 import HTTP_PROVIDERS

error message -> @ angular / http / index "'does not have an exported HTTP_PROVIDERS member.

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] 
})
+4
source share
1 answer

You no longer need HTTP_PROVIDERS (deprecated). Import the http module.

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 { }
+10
source

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


All Articles