angular - defining http as DI gives EXCEPTION: Uncaught (in promise): Error: DI Error -


i'm trying use private http: http , gives me error_handler.js:54 exception: uncaught (in promise): error: di error

i'm using http in component

component.ts

import { component, oninit } '@angular/core'; import { formbuilder, formcontrol, formgroup } '@angular/forms'; import { http} '@angular/http'; import {observable,subscription} 'rxjs/rx'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/catch'; import { nouiformatter } 'ng2-nouislider'; import {ngbmodule} '@ng-bootstrap/ng-bootstrap'; @component({   selector: 'app-char-maker',   templateurl: './char-maker.component.html',   styleurls: ['./char-maker.component.css'] }) export class charmakercomponent implements oninit {   constructor(     private formbuilder: formbuilder,     private http: http)   {      var obj;   }   ngoninit() {  } } 

if comment private http: http in constructor error goes away. i'm missing here?

for angular v4.3

you can use httpclientmodule. import from

import {httpclientmodule} '@angular/common/http'; 

and add imports

 imports: [  httpclientmodule,   //... more code   ] 

for < v4.3

you can use httpmodule , import from

import { httpmodule }    '@angular/http' 

and add imports


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -