angular - Angular2, Property 'map' does not exist on type 'Observable' -
the imports:
import { component,oninit } '@angular/core'; import { formgroup, formcontrol, validators, formbuilder } '@angular/forms'; import { application } './application'; import { http, response } '@angular/http'; import { ngmodule } '@angular/core'; import { headers } '@angular/http'; import 'rxjs/add/operator/map'; import 'rxjs/rx';
the method:
saveapplcation() { var application = new application(); application.ssnr = this.form.value.ssnr; application.loanamount = this.form.value.amount; application.email = this.form.value.email; application.phonenumber = this.form.value.phonenumber; application.repaymenttime = this.form.value.time; var body: string = json.stringify(application); var headers = new headers({ "content-type": "application/json" }); this._http.post("api/application/", body, { headers: headers }) .map(returndata => returndata.tostring()) .subscribe( retur => { this.showform = false; this.showmenu = true; }, error => alert(error), () => console.log("done post-api/loan") ); };
the error says: ts2339 property 'map' not exist on type 'observable'. typescript virtual projects c:\users\kim\documents\visual studio 2015\projects\newoblig3\newoblig3\app\app.component.ts 52 active
i've seen people import 'rxjs/add/operator/map'; , says it'll work, not in case.
you using visual studio. had same issue there.
i solved installing typescript visual studio 2015
it fixed intellisense observable.
Comments
Post a Comment