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
Post a Comment