Angular 2 - Cannot find name 'HttpClient' -


i'm trying access json feed after making changes the documentation following error

"cannot find name 'httpclient'"

i've looked on tutorial few times i'm struggling find why error.

my component perform http request.

rooms.parent.component.ts

import { component, oninit } '@angular/core';  @component({  /.../ })  export class roomparentcomponent implements oninit {   results: string[];    // inject httpclient component or service.   constructor(private http: httpclient) {}    ngoninit(): void {     // make http request:     this.http.get(/.../).subscribe(data => {       this.results = data;     });   } } 

app.module.ts

import { ngmodule } '@angular/core'; import { browsermodule } '@angular/platform-browser'; import {httpclientmodule} '@angular/common/http'; import { appcomponent } './app.component'; import { roomparentcomponent } './rooms.parent.component';  @ngmodule({   declarations: [     appcomponent,     roomparentcomponent   ],   imports: [     browsermodule,     httpclientmodule,   ],   providers: [],   bootstrap: [appcomponent] })  export class appmodule { } 

how resolve above error , inject httpclient constructor?

edit: angular version 4.3.2

httpclient got introduced in angular 4.3.0 version. have make sure have imported & injected httpclientmodule in main appmodule's imports metadata.

// import httpclientmodule @angular/common/http in appmodule import {httpclientmodule} '@angular/common/http';   //in place wanted use `httpclient` import { httpclient } '@angular/common/http'; 

Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -